Ir para conteúdo
Fórum Script Brasil

Diogo Freitas

Membros
  • Total de itens

    393
  • Registro em

  • Última visita

Tudo que Diogo Freitas postou

  1. como assim, valor de string? é k eu sou 0 em php desculpa
  2. a tua dica foi boa. grato por isso. mas continua me dando erro. <?php //pego os dados enviados pelo formulario $to = "dfreitas80@hotmail.com" . ", "; $empresa = "empresa"; $resp = "resp"; $contacto = "contacto"; $email_form = "email"; $select_tamanho = $_POST["select_tamanho"]; $select_tipo = $_POST["select_tipo"]; $select_local = $_POST["select_local"]; $select_tempo = $_POST["select_tempo"]; $coment = "coment"; $string = $to . $empresa . $resp . $contacto . $coment . $email_form; //valido os emails if (!ereg("^([0-9,a-z,A-Z]+)([.,_]([0-9,a-z,A-Z]+))*[@]([0-9,a-z,A-Z]+)([.,_,-]([0-9,a-z,A-Z]+))*[.]([0-9,a-z,A-Z]){2}([0-9,a-z,A-Z])?$", $email)){ echo"<center>Digite um email valido</center>"; echo "<center><a href=\"java script:window.history.go(-1)\">Voltar</center></a>"; exit; } //envia o email sem anexo mail( $string, $select_tamanho, $select_tipo, $select_local, $select_tempo); echo"Email enviado com Sucesso!"; ?>
  3. muito obrigado. e você não me sabe dizer como insiro parâmetros dentro de um parametro apenas? isto pk tou com 10 parametros e da erro uma vez k a função mail apenas permite 5 parametros. este código que você me deu é para colocar no html entre a head (formulário) ou no php (o que envia o formulario)?
  4. po caras.uma help ai.pf.eu sei k iss é fácil mas eu não percebo de php.pf...pena.... :( já agora, se não for pedir muito como faço para colocar campos obrigatorios? abraços
  5. Boa tarde, estou a criar um site no qual necessito de uma parte para disponibilizar a procura e oferta de emprego. Ou sej,a estou a necessitar de um sistema de postagem de procura e oferta de emprego. Alguém sabe se existe algum mecanismo já feito? lógico k não e necessario ser para postagem de emprego.essa parte eu altero abraço ajuda ai pf
  6. bom dia. Me deparei com um problema, que é o seguinte: tenho mais parâmetros dos que os permitidos na função mail. Como posso unir para que a função mail funcione? <?php //pego os dados enviados pelo formulario $to = "dfreitas80@hotmail.com" . ", "; $empresa = $_POST["empresa"]; $resp = $_POST["resp"]; $contacto = $_POST["contacto"]; $email_form = $_POST["email_form"]; $select_tamanho = $_POST["select_tamanho"]; $select_tipo = $_POST["select_tipo"]; $select_local = $_POST["select_local"]; $select_tempo = $_POST["select_tempo"]; $coment = $_POST["coment"]; //valido os emails if (!ereg("^([0-9,a-z,A-Z]+)([.,_]([0-9,a-z,A-Z]+))*[@]([0-9,a-z,A-Z]+)([.,_,-]([0-9,a-z,A-Z]+))*[.]([0-9,a-z,A-Z]){2}([0-9,a-z,A-Z])?$", $email_form)){ echo "<center>Digite um email valido</center>"; echo "<center><a href=\"java script:history.go(-1)\"><center>Voltar</center></a>"; exit; } //se não tiver anexo else{ $headers = "MIME-Version: 1.0\r\n"; $headers .= "Content-type: text/html; charset=iso-8859-1\r\n"; $headers .= "From: \"$nome\" <$email_from>\r\n"; //envia o email sem anexo mail( $to, $empresa, $resp, $contacto, $email_form, $select_tamanho, $select_tipo, $select_local, $select_tempo, $coment); echo"Email enviado com Sucesso!"; } ?>
  7. Diogo Freitas

    qual o erro?

    desculpa, mas como t disse nunca fiz disto. Se me ajudar agradeço. como ponho numa string?
  8. Diogo Freitas

    qual o erro?

    já resolvi isso mas agora me dá um erro, diz k so posso ter no maximo 5 parametros e eu tenho 10. tenho k criar headrs ne? me da uma dika pf, nunca criei <?php //pego os dados enviados pelo formulario $to = "dfreitas80@hotmail.com" . ", "; $empresa = $_POST["empresa"]; $resp = $_POST["resp"]; $contacto = $_POST["contacto"]; $email_form = $_POST["email_form"]; $select_tamanho = $_POST["select_tamanho"]; $select_tipo = $_POST["select_tipo"]; $select_local = $_POST["select_local"]; $select_tempo = $_POST["select_tempo"]; $coment = $_POST["coment"]; //valido os emails if (!ereg("^([0-9,a-z,A-Z]+)([.,_]([0-9,a-z,A-Z]+))*[@]([0-9,a-z,A-Z]+)([.,_,-]([0-9,a-z,A-Z]+))*[.]([0-9,a-z,A-Z]){2}([0-9,a-z,A-Z])?$", $email_form)){ echo "<center>Digite um email valido</center>"; echo "<center><a href=\"java script:history.go(-1)\"><center>Voltar</center></a>"; exit; } //se não tiver anexo else{ $headers = "MIME-Version: 1.0\r\n"; $headers .= "Content-type: text/html; charset=iso-8859-1\r\n"; $headers .= "From: \"$nome\" <$email_from>\r\n"; //envia o email sem anexo mail( $to, $empresa, $resp, $contacto, $email_form, $select_tamanho, $select_tipo, $select_local, $select_tempo, $coment); echo"Email enviado com Sucesso!"; } ?>
  9. Diogo Freitas

    qual o erro?

    já agora...consegues ver o k ta mal noutro formulario de recomendação que eu postei?
  10. Diogo Freitas

    qual o erro?

    fiz um código para um formulário. O que tá mal? <?php //pego os dados enviados pelo formulario $empresa = $_POST["empresa"]; $resp = $_POST["resp"]; $contacto = $_POST["contacto"]; $email_form = $_POST["email_form"]; $select_tamanho = $_POST["select_tamanho"]; $select_tipo = $_POST["select_tipo"]; $select_local = $_POST["select_local"]; $select_tempo = $_POST["select_tempo"]; $coment = $_POST["coment"]; //valido os emails if (!ereg("^([0-9,a-z,A-Z]+)([.,_]([0-9,a-z,A-Z]+))*[@]([0-9,a-z,A-Z]+)([.,_,-]([0-9,a-z,A-Z]+))*[.]([0-9,a-z,A-Z]){2}([0-9,a-z,A-Z])?$", $email_from)){ echo "<center>Digite um email valido</center>"; echo "<center><a href=\"java script:history.go(-1)\"><center>Voltar</center></a>"; exit; } //se não tiver anexo else{ $headers = "MIME-Version: 1.0\r\n"; $headers .= "Content-type: text/html; charset=iso-8859-1\r\n"; $headers .= "From: \"$nome\" <$email_from>\r\n"; //envia o email sem anexo mailto:geral@uttil.com($empresa,$resp,$contacto,$email_form,$select_tamanho,$select_tipo,$select_local,$select_tempo,$coment); echo"Email enviado com Sucesso!"; } ?>
  11. desculpa, eu sei k não devia tar a mandar outro post pois vai contra as regras do forum mas po, eu sei k isto e um problema facil d resolver.so k eu não sei.lol.abraço
  12. Boa tarde, Desde há algum tempo que tento encontrar um script de um sistema de comentários para notícias, mas que esteja integrado numa página, ou seja, um sistema dentro de um layout que eu criei e não um blog externo. Visto não ter encontrado nada até agora, pensei que talvez não fosse muito dificil criar um. Gostava da vossa opiniao acerca de como criar esse script de forma simples e eficaz. obrigados
  13. obrigado. instalei o b2evolution. mas aquilo é um blog aparentemente. como configuro para ficar tipo aquele link que te mandei. ou seja, um sistema de comentários.
  14. bons dias. alguém me sabe dizer como se faz ou se há feito (era bem melhor.lol), um sistema de blog como esse? undefined
  15. obrigado pela dica. olha ai o erro Notice: Undefined index: url in /srv/www/vhosts/uttil.com/httpdocs/ficheiros/scripts/recomendar/mailto.php on line 36
  16. Antes de mais obrigado pela outra dica. Bem, o mal é mesmo esse,é que não aparece erro nenhum.. Simplesmente não funciona. Não dá echo nenhum. Nem quando o mail tá errado
  17. Boa tarde, este formulário de recomendação simplesmente não está funcionando. Mas aparentemente está tudo ok. Dá para dar uma chekada? agradeço desde já. <?PHP error_reporting(134); # Script name : el8.recommend # Version : 1.0 # Description : Inform someone about page you are currently on # Extra info : This script uses JavaScript to pop up a window with the form. # # Read readme.txt # # -[ hr.el8.web # -[ made by Slaven Bacelic # -[ e-mail: slaven.bacelic@ri.hinet.hr # # Edit variables below: # # Title of the "poped" page: $GLOBALS["title"]="Recomendar esta página a um colega"; # Path to mailto.php script: $GLOBALS["path"]="mailto.php"; # Site name: $GLOBALS["site_name"]="Uttil.com"; # webmaster's email: $GLOBALS["your_email"]="geral@uttil.com"; # Last words: You can distribute this script freely as long as my name and email are in header! ############################ DO NOT EDIT BELOW ################################ function show_form() { ?> <html> <head> <title><?PHP echo $GLOBALS["title"]; ?></title> </head> <body> Recomendar <b><?PHP echo $GLOBALS["url"]; ?></b> a um amigo... <form method="post" action="<?PHP echo $GLOBALS["../../../../../../DOCUME~1/BRINCO~1/DEFINI~1/Temp/Rar$DI00.766/path"]; ?>"> <input type=hidden name="url" value="<?PHP echo $GLOBALS["url"]; ?>"> <table width="90%" border="0" cellspacing="0" cellpadding="0"> <tr align="left" valign="top"> <td width="50%"> Nome: </td> <td> <input type="text" name="form[from]" size="30"> </td> </tr> <tr align="left" valign="top"> <td> <small>*</small> Email: </td> <td> <input type="text" name="form[from_email]" maxlength="40" size="30"> </td> </tr> <tr align="left" valign="top"> <td> <small>*</small> Email do colega:</td> <td> <input type="text" name="form[to_email]" size="30"> </td> </tr> <tr align="left" valign="top"> <td> Comentário acerca do uttil.com: </td> <td> <textarea name="form[comment]" rows="5" cols="30"></textarea> </td> </tr> <tr align="left" valign="top"> <td> <input type="submit" name="submit" value="Send"> <input type="reset" name="Reset" value="Reset"> </td> <td>&nbsp;</td> </tr> </table> <p><small>* - obrigatório!</small></p> </form> </body> </html> <?PHP } function error($string) { print ("<div align=center valign=center><b>Atenção:</b> $string<br><br> | [ <a href=\"java script:window.close()\">Fechar esta janela</a> ] </div>"); exit; } function check_email ($address) { # this function was copied from PHP mailing list return (ereg('^[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+'.'@'.'[-!#$%&\'*+\\/0-9=?A-Z^_`a-z{|}~]+\.'.'[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+$',$address)); } if (isset($submit)) { if (! check_email ($form["from_email"]) || ! check_email ($form["to_email"]) ) error ("Endereço de email inválido!"); $date=date( "D, j M Y H:i:s -0600"); $to_email=$form["to_email"]; $from=$form["from"]; $from_email=$form["from_email"]; $comment=$form["comment"]; $site_name=$GLOBALS["site_name"]; $your_email=$GLOBALS["your_email"]; $message="Hi!\n\n$from ($from_email) invited you to visit $site_name!\nCheck out this URL: $url"; if ($form["comment"] != "") { $message.="\n\n$from left you a note:\n$comment"; } $message.="\n\n\n-------------------------------------------------------------------\nSend script!"; $subject="Foi convidado por $from a visitar ".$GLOBALS["site_name"]."!"; $add="From: $site_name <$your_email>\nReply-To: $from_email\nDate: $date\n"; if (@mail ("$to_email","$subject","$message","$add")) { echo "<center>Mensagem enviada com sucesso!<br>Obrigado!<br><br>[ <a href=\"java script:window.close()\">Close this window</a> ]</center>"; } else error ("Neste momento foi impossível enviar o email. Por favor tente mais tarde!"); } else show_form(); ?>
  18. alô alô... me ajuda pf
  19. por favor, alguém me dá uma ajuda? O único problema k estou enfrentando é não conseguir colocar dois layer desses na mesma página. abraço
  20. Boa tarde, Arrangei um script em JavaScript de um player de video. Está a funcionar correctamente, o problema é que não consigo colocar dois players na mesma página. vou mandar o código no html: <script type="text/javascript" src="swfobject.js"></script> <div id="player">This text will be replaced</div> <script type="text/javascript">var so = new SWFObject('mediaplayer.swf','mpl','470','255','8');so.addParam('allowscriptaccess','always');so.addParam('allowfullscreen','true');so.addVariable('height','255');so.addVariable('width','470');so.addVariable('file','videos/lenny_again.flv');so.addVariable('frontcolor','0x666666');so.addVariable('lightcolor','0x666666');so.addVariable('screencolor','0x888888');so.write('player');</script> o código java script: if(typeof deconcept == "undefined") var deconcept = new Object(); if(typeof deconcept.util == "undefined") deconcept.util = new Object(); if(typeof deconcept.SWFObjectUtil == "undefined") deconcept.SWFObjectUtil = new Object(); deconcept.SWFObject = function(swf, id, w, h, ver, c, quality, xiRedirectUrl, redirectUrl, detectKey) { if (!document.getElementById) { return; } this.DETECT_KEY = detectKey ? detectKey : 'detectflash'; this.skipDetect = deconcept.util.getRequestParameter(this.DETECT_KEY); this.params = new Object(); this.variables = new Object(); this.attributes = new Array(); if(swf) { this.setAttribute('swf', swf); } if(id) { this.setAttribute('id', id); } if(w) { this.setAttribute('width', w); } if(h) { this.setAttribute('height', h); } if(ver) { this.setAttribute('version', new deconcept.PlayerVersion(ver.toString().split("."))); } this.installedVer = deconcept.SWFObjectUtil.getPlayerVersion(); if (!window.opera && document.all && this.installedVer.major > 7) { // only add the onunload cleanup if the Flash Player version supports External Interface and we are in IE deconcept.SWFObject.doPrepUnload = true; } if(c) { this.addParam('bgcolor', c); } var q = quality ? quality : 'high'; this.addParam('quality', q); this.setAttribute('useExpressInstall', false); this.setAttribute('doExpressInstall', false); var xir = (xiRedirectUrl) ? xiRedirectUrl : window.location; this.setAttribute('xiRedirectUrl', xir); this.setAttribute('redirectUrl', ''); if(redirectUrl) { this.setAttribute('redirectUrl', redirectUrl); } } deconcept.SWFObject.prototype = { useExpressInstall: function(path) { this.xiSWFPath = !path ? "expressinstall.swf" : path; this.setAttribute('useExpressInstall', true); }, setAttribute: function(name, value){ this.attributes[name] = value; }, getAttribute: function(name){ return this.attributes[name]; }, addParam: function(name, value){ this.params[name] = value; }, getParams: function(){ return this.params; }, addVariable: function(name, value){ this.variables[name] = value; }, getVariable: function(name){ return this.variables[name]; }, getVariables: function(){ return this.variables; }, getVariablePairs: function(){ var variablePairs = new Array(); var key; var variables = this.getVariables(); for(key in variables){ variablePairs.push(key +"="+ variables[key]); } return variablePairs; }, getSWFHTML: function() { var swfNode = ""; if (navigator.plugins && navigator.mimeTypes && navigator.mimeTypes.length) { // netscape plugin architecture if (this.getAttribute("doExpressInstall")) { this.addVariable("MMplayerType", "PlugIn"); this.setAttribute('swf', this.xiSWFPath); } swfNode = '<embed type="application/x-shockwave-flash" src="'+ this.getAttribute('swf') +'" width="'+ this.getAttribute('width') +'" height="'+ this.getAttribute('height') +'"'; swfNode += ' id="'+ this.getAttribute('id') +'" name="'+ this.getAttribute('id') +'" '; var params = this.getParams(); for(var key in params){ swfNode += [key] +'="'+ params[key] +'" '; } var pairs = this.getVariablePairs().join("&"); if (pairs.length > 0){ swfNode += 'flashvars="'+ pairs +'"'; } swfNode += '/>'; } else { // PC IE if (this.getAttribute("doExpressInstall")) { this.addVariable("MMplayerType", "ActiveX"); this.setAttribute('swf', this.xiSWFPath); } swfNode = '<object id="'+ this.getAttribute('id') +'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+ this.getAttribute('width') +'" height="'+ this.getAttribute('height') +'">'; swfNode += '<param name="movie" value="'+ this.getAttribute('swf') +'" />'; var params = this.getParams(); for(var key in params) { swfNode += '<param name="'+ key +'" value="'+ params[key] +'" />'; } var pairs = this.getVariablePairs().join("&"); if(pairs.length > 0) {swfNode += '<param name="flashvars" value="'+ pairs +'" />';} swfNode += "</object>"; } return swfNode; }, write: function(elementId){ if(this.getAttribute('useExpressInstall')) { // check to see if we need to do an express install var expressInstallReqVer = new deconcept.PlayerVersion([6,0,65]); if (this.installedVer.versionIsValid(expressInstallReqVer) && !this.installedVer.versionIsValid(this.getAttribute('version'))) { this.setAttribute('doExpressInstall', true); this.addVariable("MMredirectURL", escape(this.getAttribute('xiRedirectUrl'))); document.title = document.title.slice(0, 47) + " - Flash Player Installation"; this.addVariable("MMdoctitle", document.title); } } if(this.skipDetect || this.getAttribute('doExpressInstall') || this.installedVer.versionIsValid(this.getAttribute('version'))){ var n = (typeof elementId == 'string') ? document.getElementById(elementId) : elementId; n.innerHTML = this.getSWFHTML(); return true; }else{ if(this.getAttribute('redirectUrl') != "") { document.location.replace(this.getAttribute('redirectUrl')); } } return false; } } /* ---- detection functions ---- */ deconcept.SWFObjectUtil.getPlayerVersion = function(){ var PlayerVersion = new deconcept.PlayerVersion([0,0,0]); if(navigator.plugins && navigator.mimeTypes.length){ var x = navigator.plugins["Shockwave Flash"]; if(x && x.description) { PlayerVersion = new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/, "").replace(/(\s+r|\s+b[0-9]+)/, ".").split(".")); } }else{ // do minor version lookup in IE, but avoid fp6 crashing issues // see http://blog.deconcept.com/2006/01/11/getvariable-setvariable-crash-internet-explorer-flash-6/ try{ var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7"); }catch(e){ try { var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6"); PlayerVersion = new deconcept.PlayerVersion([6,0,21]); axo.AllowScriptAccess = "always"; // throws if player version < 6.0.47 (thanks to Michael Williams @ Adobe for this code) } catch(e) { if (PlayerVersion.major == 6) { return PlayerVersion; } } try { axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash"); } catch(e) {} } if (axo != null) { PlayerVersion = new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(",")); } } return PlayerVersion; } deconcept.PlayerVersion = function(arrVersion){ this.major = arrVersion[0] != null ? parseInt(arrVersion[0]) : 0; this.minor = arrVersion[1] != null ? parseInt(arrVersion[1]) : 0; this.rev = arrVersion[2] != null ? parseInt(arrVersion[2]) : 0; } deconcept.PlayerVersion.prototype.versionIsValid = function(fv){ if(this.major < fv.major) return false; if(this.major > fv.major) return true; if(this.minor < fv.minor) return false; if(this.minor > fv.minor) return true; if(this.rev < fv.rev) return false; return true; } /* ---- get value of query string param ---- */ deconcept.util = { getRequestParameter: function(param) { var q = document.location.search || document.location.hash; if(q) { var pairs = q.substring(1).split("&"); for (var i=0; i < pairs.length; i++) { if (pairs[i].substring(0, pairs[i].indexOf("=")) == param) { return pairs[i].substring((pairs[i].indexOf("=")+1)); } } } return ""; } } /* fix for video streaming bug */ deconcept.SWFObjectUtil.cleanupSWFs = function() { var objects = document.getElementsByTagName("OBJECT"); for (var i=0; i < objects.length; i++) { objects[i].style.display = 'none'; for (var x in objects[i]) { if (typeof objects[i][x] == 'function') { objects[i][x] = function(){}; } } } } // fixes bug in fp9 see http://blog.deconcept.com/2006/07/28/swfobject-143-released/ if (deconcept.SWFObject.doPrepUnload) { deconcept.SWFObjectUtil.prepUnload = function() { __flash_unloadHandler = function(){}; __flash_savedUnloadHandler = function(){}; window.attachEvent("onunload", deconcept.SWFObjectUtil.cleanupSWFs); } window.attachEvent("onbeforeunload", deconcept.SWFObjectUtil.prepUnload); } /* add Array.push if needed (ie5) */ if (Array.prototype.push == null) { Array.prototype.push = function(item) { this[this.length] = item; return this.length; }} /* add some aliases for ease of use/backwards compatibility */ var getQueryParamValue = deconcept.util.getRequestParameter; var FlashObject = deconcept.SWFObject; // for legacy support var SWFObject = deconcept.SWFObject; abraço
  21. bom dia, ando há já muito tempo tentando encontrar um player de mp3 e video para um site. encontrei esse aqui mas não tou conseguindo colocá-lo para funcionar. checa ai o website do player e faz download abraço
  22. bem, andei mexendo ai nuns tutoriais e consegui fazer algo.porém ainda não está em linha. pf me ajudem. css: .tabela{ width:auto; height:20px; } ul { margin:0; padding:0; list-style:none; width:1%; height:20px; } ul li{ position:relative; } li ul{ position:absolute; top:19px; left:0px; display:none; } ul li a{ text-decoration:none; color:#666666; } li:hover ul {display:block; } html: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> </head><link rel="stylesheet" href="teste.css" /> <body class="tabela"> <div class="tabela"> <ul> <li><a href="#">Semana</a> <ul> <li><a href="#">noticia 1</a></li></ul></li></ul> <ul> <li><a href="#">Semana</a> <ul> <li><a href="#">noticia 1</a></li></ul></li></ul> </div> </body> </html> abraço
  23. po cara, muito obrigado. Me diz pf so mais uma coisa. O anexo não está a ser enviado. Para que seja basta colocar $arquivo no mail correto? mail($email_envio,$assunto,$mensagem,$arquivo, $headers);
  24. Boa tarde, Achei este código num tutorial aqui no scriptbrasil. Fiz umas pequeninas alterações em termos de layout. Tou com um problema que é o seguinte, o código é para enviar mails atraves de um site e com anexo. mas eu queria transformar o código para que os mails fossem todos para um email especificado.Por isso fiz o seguinte. Código html: <html> <head> <script language="javascript" type="text/javascript"> function checa_formulario(email){ if (email.nome.value == ""){ alert("Por Favor não deixe o seu nome em branco!!!"); email.nome.focus(); return (false); } if (email.email_from.value == ""){ alert("Por Favor não deixe o seu email em branco!!!"); email.email_from.focus(); return (false); } if (email.email.value == ""){ alert("não deixe o email destinatario em branco!!!"); email.email.focus(); return (false); } if (email.assunto.value == ""){ alert("não deixe o assunto em branco!!!"); email.assunto.focus(); return (false); } } </script> <title>Enviando texto</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <style type="text/css"> <!-- .email { text-transform: lowercase; } .texto { color: #999999; font-family:Verdana, Arial, Helvetica, sans-serif } .style1 {color: #666666; font-family:Verdana, Arial, Helvetica, sans-serif} --> </style> </head> <body onLoad="document.email.nome.focus();"> <form onSubmit="return checa_formulario(this)" action="envia2.php" method="post" enctype="multipart/form-data" name="email"> <h1 align="center" class="style1">Formulario de email com anexo </h1> <table width="32%" border="0" align="center"> <tr> <td><div align="right"><span class="texto">Nome</span></div></td> <td><input name="nome" type="text" id="nome"></td> </tr> <tr> <td width="33%"><div align="right" class="texto">De:</div></td> <td width="67%"><input name="email_from" type="text" class="email"></td> </tr> <tr> <td>&nbsp;</td> <td> </tr> <tr> <td><div align="right" class="texto">Assunto</div></td> <td><input name="assunto" type="text" id="assunto"></td> </tr> <tr> <td><div align="right" class="texto">Mensagem</div></td> <td><textarea name="mensagem" cols="50" rows="10" id="mensagem"></textarea></td> </tr> <tr> <td><div align="right" class="texto">Anexo</div></td> <td><input name="arquivo" type="file"></td> </tr> <tr> <td> </td> <td><input type="submit" name="Submit" value="Enviar"></td> </tr> </table> </form> </body> </html> código php: <?php $email_envio = "geral@uttil.com"; //pego os dados enviados pelo formulario $nome = $_POST["nome"]; $mensagem = $_POST["mensagem"]; $assunto = $_POST["assunto"]; $email_from = $_POST["email_from"]; //formato o campo da mensagem $mensagem = wordwrap( $mensagem, 50, "<br>", 1); //valido os emails if (!ereg("^([0-9,a-z,A-Z]+)([.,_]([0-9,a-z,A-Z]+))*[@]([0-9,a-z,A-Z]+)([.,_,-]([0-9,a-z,A-Z]+))*[.]([0-9,a-z,A-Z]){2}([0-9,a-z,A-Z])?$", $email_from)){ echo "<center>Digite um email valido</center>"; echo "<center><a href=\"java script:history.go(-1)\"><center>Voltar</center></a>"; exit; } $arquivo = isset($_FILES["arquivo"]) ? $_FILES["arquivo"] : FALSE; if(file_exists($arquivo["tmp_name"]) and !empty($arquivo)){ $fp = fopen($_FILES["arquivo"]["tmp_name"],"rb"); $anexo = fread($fp,filesize($_FILES["arquivo"]["tmp_name"])); $anexo = base64_encode($anexo); fclose($fp); $anexo = chunk_split($anexo); $boundary = "XYZ-" . date("dmYis") . "-ZYX"; $mens = "--$boundary\n"; $mens .= "Content-Transfer-Encoding: 8bits\n"; $mens .= "Content-Type: text/html; charset=\"ISO-8859-1\"\n\n"; //plain $mens .= "$mensagem\n"; $mens .= "--$boundary\n"; $mens .= "Content-Type: ".$arquivo["type"]."\n"; $mens .= "Content-Disposition: attachment; filename=\"".$arquivo["name"]."\"\n"; $mens .= "Content-Transfer-Encoding: base64\n\n"; $mens .= "$anexo\n"; $mens .= "--$boundary--\r\n"; $headers = "MIME-Version: 1.0\n"; $headers .= "From: \"$nome\" <$email_from>\r\n"; $headers .= "Content-type: multipart/mixed; boundary=\"$boundary\"\r\n"; $headers .= "$boundary\n"; //envio o email com o anexo mail($email,$assunto,$mens,$headers); echo"Email enviado com Sucesso!"; } //se não tiver anexo else{ $headers = "MIME-Version: 1.0\r\n"; $headers .= "Content-type: text/html; charset=iso-8859-1\r\n"; $headers .= "From: \"$nome\" <$email_from>\r\n"; //envia o email sem anexo mail($email,$assunto,$mensagem, $headers); echo"Email enviado com Sucesso!"; } ?> abraço
×
×
  • Criar Novo...