madness69 Posted March 13, 2011 Share Posted March 13, 2011 hi there guys, i have right a email form, and it works very well, but im having some trouble whit something, how can i make it possible to have a attachement file whit him, take a look of my code please: <?php $nome=$_POST["nome"]; $morada=$_POST["morada"]; $CodPostal1=$_POST["CodPostal1"]; $CodPostal2=$_POST["CodPostal2"]; $localidade=$_POST["localidade"]; $telefone=$_POST["telefone"]; $email=$_POST["email"]; $comentarios=$_POST["comentarios"]; ?> <form action="?p=recrutamento" method="post" name="form_contactos" id="contactos"> <?php if($dados) {echo "Por favor preencha os campos em falta.";} ?> <p style="width:220px;">Nome <input name="nome" type="text" id="nome" style="width:220px; float:left;" tabindex="1" size="220"> <?php if($dados && $nome=="");?></p> <p style="width:450px;">Morada <input name="morada" type="text" id="morada" style="width:450px; float:left;" tabindex="3" size="410"> <?php if($dados && $morada=="");?></p> <p style="width:230px;">Código Postal<br /> <input name="CodPostal1" type="text" id="CodPostal1" maxlength="4" style="width:25px;float:left" tabindex="4"> <?php if($dados && $CodPostal1=="");?> <input name="CodPostal2" type="text" id="CodPostal2" maxlength="3" style="width:18px;margin-left:5px;float:left;" tabindex="5"> <?php if($dados && $CodPostal2=="");?> <input name="localidade" type="text" id="localidade" style="width:155px;float:left; margin-left:5px;" tabindex="6"> <?php if($dados && $localidade=="");?> </p> <p>Tel./Tlm. <input name="telefone" type="text" id="telefone" style="width:210px;float:left;" tabindex="7"> <?php if($dados && $telefone=="");?> </p> <p style="width:220px;float:left;">E-mail<input name="email" type="text" id="email" style="width:220px; float:left;" tabindex="8"> <?php if($dados && $email=="");?> </p> <p style="width:450px;margin-left:20px;float:left;">file atachement </p> <p style="width:450px;">Mensagem: <textarea name="comentarios" rows="3" id="comentarios" style="width:450px;float:left;" tabindex="9"></textarea> <?php if($dados && $comentarios=="");?> </p> <p style="width:450px;">Protecão</p> <p style="width:100px;"> <img src="captcha/code.php" name="img_codigo" width="100" height="17" border="0" id="img_codigo" style="border:1px solid #abadb3; float:left;" ></p> <a href="javascript:void(0);" onclick="actualiza_captcha();"><img src="images/refresh.png" alt="actualizar" title="actualizar" width="16" height="16" border="0" style="float:left;margin-left:15px;margin-top:5px;" ></a> <p style="width:90px;"><input name="codigo" type="text" class="texto2" id="codigo" style="width:80px; float:left;" tabindex="10" maxlength="5"> </p> <p style="width:70px;float:left;"> <img src="images/limpar.jpg" alt="LIMPAR" border="0" style="cursor:pointer; width:70px; height:19px ;float:left;margin-left:0px;" title="LIMPAR" onClick="javascript:form_contactos.reset();"> <p style="width:90px;"><input name="enviar" type="image" onClick="return Form_Validator(form_contactos);" src="images/enviar.jpg" alt="ENVIAR" title="ENVIAR" style="height:19px; width:70px; border:none; float:left;"></p> </form> Than is redirect to this page to validate some info: <?php $nome=$_POST["nome"]; $morada=$_POST["morada"]; $CodPostal1=$_POST["CodPostal1"]; $CodPostal2=$_POST["CodPostal2"]; $localidade=$_POST["localidade"]; $telefone=$_POST["telefone"]; $email=$_POST["email"]; $comentarios=$_POST["comentarios"]; if (($nome != null) && ($morada != null) && ($CodPostal1 != null) && ($CodPostal2 != null) && ($localidade != null) && ($telefone != null) && ($email != null) && ($comentarios != null)) { include "final_recrutamento.php"; } else { $dados=true; include "contactos_recrutamento.php"; } ?> And finally to this page to have his action: <?php $nome=$_POST["nome"]; $morada=$_POST["morada"]; $CodPostal1=$_POST["CodPostal1"]; $CodPostal2=$_POST["CodPostal2"]; $localidade=$_POST["localidade"]; $telefone=$_POST["telefone"]; $email=$_POST["email"]; $comentarios=$_POST["comentarios"]; ?> <p><img src="imagens/separador_esq.png" alt="separador" /></p> <div class="submenu_contactos"> <?php include ("submenu_contactos.php"); ?></div> <div class="contactos_empresa_orcamentos"> <h1>quer fazer parte da nossa equipa?</h1> <p style="width:400px;line-height:1.6;float:left;"><?php $headers = "From: $email" . "\r\n" . "Content-type: text/plain; charset=utf-8" . "\r\n" . "X-Mailer: PHP/" . phpversion(); $to = "myemail"; $subject = "Formulário de recrutamento - site"; $body = "nome: $nome, morada: $morada, código postal: $CodPostal1 - $CodPostal2 $localidade, telefone: $telefone, email: $email, mensagem: $comentarios"; if (mail( $to , $subject , $body, $headers )) { echo("$nome, your file had been saved.<br /> Will be contacting.<br /> Thanks."); } else { echo("$nome, a error.<br /> Try again.<br /> Thanks. "); } ?></p> </div> Quote Link to comment Share on other sites More sharing options...
madness69 Posted March 15, 2011 Author Share Posted March 15, 2011 no help? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.