Jump to content

Recommended Posts

Hey guys newbie here.

 

I have a problem with a information form on a website. It seems the data written by the form isn't being sent out to the e-mail. In several testings, I every time receive a blank e-mail.

 

The information form is located on the same code of the php.

 

Can you help me out?

 

Thanks.

 

Here is the code:

 

 

<?
 
//intContactos.php
 
?>
 
<?
function intContactosHome() {
 
if( $_SERVER['REQUEST_METHOD'] == "POST" ) {
 
$origem = $HTTP_POST_VARS["origem"];
$nome = $HTTP_POST_VARS["nome"];
$telefone = $HTTP_POST_VARS["telefone"];
$email = $HTTP_POST_VARS["e_mail"];
$informacao    = $HTTP_POST_VARS["informacao"];
 
 
/* assunto */
$subject = "Pedido de informações";
 
$url = ($_SERVER['REMOTE_ADDR'] != "127.0.0.1") ? ;
 
$html = "";
 
if( $origem != "" )   $html .= "Origem do contacto: $origem<br>";
if( $nome != "" )   $html .= "Nome: $nome<br>";
if( $telefone != "" ) $html .= "Telefone / Telemóvel: $telefone<br>";
if( $email != "" ) $html .= "E-mail: <a href=\"$email\">$email</a><br>";
if( $informacao != "" ) $html .= "<br>Informação pretendida: $informacao<br><br>";
 
 
/* destinatário */
switch( $origem ) {
case "Cliente":
$to  = "MAIL A";
break;
case "Fornecedor":
$to  = "MAIL A>";
break;
case "Recrutamento":
$to  = "MAIL A";
break;
default:
$to  = "MAIL A>";
break;
}
 
/* mensagem */
$message = '
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Mundopal</title>
<style>
.tdNorm {color:#014262;font-family:verdana;font-size:11px;line-height:150%}
</style>
</head>
<body bgcolor="#FFFFFF">
<table align="left" border="0" cellpadding="0" cellspacing="0" width="460">
 <tr>
<td style="padding:10px">
<table align="left" border="0" cellpadding="0" cellspacing="0" width="100%">
 <tr>
<td align="right" valign="top"><img src="' . $url . 'logo.gif"></td>
 </tr>
 <tr><td height="20"></td></tr>
 <tr>
<td align="left" valign="top" style="padding-bottom:20px;font-size:13px" class="tdNorm">
<b>' . $subject . ' - ' . date('d.m.Y', strtotime("now")) . '</b></td>
 </tr>
 <tr>
<td align="left" valign="top" class="tdNorm" style="padding-bottom:20px">
' . $html . '</td>
 </tr>
 <tr><td height="1" bgcolor="#014262"></td></tr>
 <tr>
<td align="right" valign="top" class="tdNorm" style="padding-top:0px;font-size:9px">
Mensagem enviada a partir do site <a href="lalala.com">lalala.com</a></td>
 </tr>
</table>
</td>
 </tr>
</table>
 
<script language="JavaScript1.2" src="scripts/rclick.js"></script>
 
</body>
</html>';
 
/* header Content-type: HTML */
$headers  = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
 
/* headers adicionais */
//$headers .= "To: something";
$headers .= "From: something@mail\r\n";
//$headers .= "Bcc: something@mail\\r\n";
//$to = "something@mail";
 
/* Enviar o email */
$result = ( mail( $to, $subject, $message, $headers ) ) ? "<font color=\"#00004B\">O seu pedido de informações foi enviado com sucesso!<br>Um responsável da nossa equipa entrará em contacto consigo brevemente.<br><br>Obrigado!</font>" : "<font color=\"#8B0000\">N�o foi poss�vel enviar o seu pedido.<br><br>Por favor tente de novo.</font>";
//$result = "asdasdsa";
}
else
$result = '';
 
?> 
 
<table width="605" cellpadding="0" cellspacing="0" border="0">
<tr>
<td>
<img src="images/titulos/tit_contactos.gif" alt="Contactos" width="190" height="24" border="0">
</td>
</tr>
<tr>
<td height="10"></td>
</tr>
 
<tr>
<td>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td valign="top">
 </td>
 <td valign="top">
<p><strong>E-mails</strong>:<br />
- <a href="mailto:something@mail</a><br />
 - <a href="mailto:something@mail</a><br />
 - <a href="mailto:isomething@mail</a><br />
 - <a href="mailto:something@mail</a><br />
   </td>
 <td valign="top">
<p> <br />
 - <a href="mailto:something@mail">something@mail</a><br />
 - <a href="mailto:something@mail">something@mail</a><br />
 - <a href="mailto:something@mail">fsomething@mail</a></p>
   </td>
</tr>
</table>
</td>
</tr>
 
<tr>
<td height="30"></td>
</tr>
 
<tr>
<td><strong>Pedido de informações</strong>:</td>
</tr>
 
<tr>
<td height="10"></td>
</tr>
 
<tr>
<td width="605">
 <?
 if( $result != '' ) {
 
echo '
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr bgcolor="#e5e5e5">
<td width="10" nowrap="nowrap"></td>
<td height="25" width="100%">' . $result . '</td>
<td width="10" nowrap="nowrap"></td>
</tr>
</table>';
 
 }
 else { ?>
 
 <form name="form1" method="POST" action="<? echo $_SERVER['PHP_SELF'] ?>" onSubmit="checkFields(); return document.MM_returnValue">
 <table width="100%" border="0" cellpadding="0" cellspacing="1">
  <tr id="trNotFilledMsg" style="display:none;"><td class='not_filled_msg' colspan="2"><b>:: Por favor preencha os campos assinalados<br><br></b></td></tr>
  <tr><td colspan="2"></td></tr>
  <tr>
<td>Origem do contacto <span class="obrig" id="tdnome">(*)</span> </td></tr><tr>
<td>
<select name="origem" style="width:100%">
<option value=""></option>
<option value="Geral">Geral</option>
<option value="Cliente">Cliente</option>
<option value="Fornecedor">Fornecedor</option>
<option value="Recrutamento">Recrutamento</option>
</select></td>
  </tr>
  <tr><td height="10"></td></tr>
  <tr>
<td>Nome <span class="obrig" id="tdnome">(*)</span> </td></tr><tr>
<td><input style="width:100%" obrig="1" descricao="Nome" type="text" class="inputText" name="nome" size="60" value=""></td>
  </tr>
  <tr><td height="10"></td></tr>
  <tr>
<td>E-mail <span class="obrig" id="tdemail">(*)</span> </td></tr><tr>
<td><input style="width:100%" obrig="1" descricao="E-mail" type="text" class="inputText" name="e_mail" size="60" value="">
</td>
  </tr>
  <tr><td height="10"></td></tr>
  <tr>
<td>Telefone / Telemóvel <span class="obrig" id="tdtelefone">(*)</span> </td></tr><tr>
<td><input style="width:100%" obrig="1" descricao="Telefone / Telemóel" type="text" class="inputText" name="telefone" size="30" value="">
</td>
  </tr>
  <tr><td height="10"></td></tr>
  <tr>
<td valign="top">Informação Pretendida <span class="obrig" id="tdinformacao">(*)</span> </td></tr><tr>
<td><textarea style="width:100%" obrig="1" descricao="Informação Pretendida" name="informacao" rows="6"></textarea>
</td>
  </tr>
  <tr><td height="10"></td></tr>
<tr>
<td colspan="2">
  <table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
 <td align="left" width="50%" nowrap>
<span class="obrig">(*)</span> Campos obrigatórios
</td>
 <td align="right" valign="top">
<input class="inputBt" type="submit" value="   Enviar   " name="enviar"></td>
  </tr>
 </table>
 </td>
</tr>
</table>
  </form> <?
  
  } ?>
Link to comment
https://forums.phpfreaks.com/topic/284358-code-error-on-information-form/
Share on other sites

Headers and boundary headers need to be escaped using two line feeds (to create an empty row) in emails. So try changing the last row of your $header variable to end with "\r\n\r\n". I read somewhere though that the "\r" may not be needed (I forget why) but you can try with and without.

 

HTH

Edited by jay20aiii
Thanks for the prompt reply however I now have this error.

 

Warning: mail() [function.mail]: Bad parameters to mail() function, mail not sent. in/home/content/70/8329570/html/interface/intContactos_copy.php on line 102

 


$result = ( mail ( $subject, $message, $html ) ) ? "<font color=\"#00004B\">O seu pedido de informações foi enviado com sucesso!<br>Um responsável da nossa equipa entrará em contacto consigo brevemente.<br><br>Obrigado!</font>" : "<font color=\"#8B0000\">Nao foi possivel enviar o seu pedido.<br><br>Por favor tente de novo.</font>";

//$result = "asdasdsa";

}

else

$result = '';

i'm not exactly sure what this line is meant to be:

$url = ($_SERVER['REMOTE_ADDR'] != "127.0.0.1") ? ;

it looks like an attempted ternary operator, but it is incomplete and makes no sense in the way $url is used below. i changed it to this:

$url = $_SERVER['REMOTE_ADDR'];

also, did you listen to gristoi and change http_post_vars to _post?

        $origem = $_POST["origem"];
        $nome = $_POST["nome"];
        $telefone = $_POST["telefone"];
        $email = $_POST["e_mail"];
        $informacao    = $_POST["informacao"];
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.