Page 1 of 1

php email problem

Posted: Tue Feb 19, 2008 12:45 pm
by plodos
I have a problem email script is working but not correctly...

Problem is mixing the HTML codes and form informations..I upload the OUTPUT of the email...
Image
Did u check the link?..informations are not clear...

And also source codes are here, http://www.2shared.com/file/2868783/4e4fbc1b/code.html
Could you check it for me...Maybe I didnt see the errors:S

Code: Select all

 
<?php
$fullname = $_REQUEST["fullname"];
$country = $_REQUEST["country"];
$institution = $_REQUEST["institution"];
$subject = $_REQUEST["subject"];
$message = $_REQUEST["message"];
$from = $_REQUEST["from"];
$verif_box = $_REQUEST["verif_box"];
 
$now = time();
$date = date("d/m/Y H:i:s",$now);
$ip = $_SERVER['REMOTE_ADDR'];
 
$content ="<table width=522 height=235 border=1>";
$content .="<tbody><tr><td width=506 height=23 bgcolor=#FFFFFF colspan=2>";
$content .="<center>ONLINE FORM </center> <br>";
$content .="Date : $date             IP Adress :$ip";
$content .="</td></tr>";
$content .="<tr><td width=105 height=23 bgcolor=#CCCCCC>Full Name </td>";
$content .="<td width=403 bgcolor=#CCCCCC>$fullname</td></tr>";
$content .="<tr><td height=23 valign=top>Institution</td>";
$content .="<td>$institution</td></tr>";
$content .="<tr><td bgcolor=#CCCCCC>Country</td>";
$content .="<td bgcolor=#CCCCCC>$country</td></tr>";
$content .="<tr><td height=29>From</td>";
$content .="<td>$from</td></tr>";
$content .="<tr>";
$content .="<td height=25 bgcolor=#CCCCCC>Comments</td>";
$content .="<td bgcolor=#CCCCCC>$message</td>";
$content .="</tr>";
$content .="</tbody>";
$content .="</table>";
 
 
$headers = "ONLINE FORM <$from>\n";
$headers .= 'MIME-Version: 1.0' . "\n";
$headers .= 'Content-type: text/html; charset=iso-8859-9' . "\n";
 
 
if(md5($verif_box).'a4xn' == $_COOKIE['tntcon']){
    mail("seas@gmail.com", 'ONLINE FORM: '.$subject,$content,$headers);
    setcookie('tntcon','');
} else {
    header("Location:".$_SERVER['HTTP_REFERER']."?subject=$subject&fullname=$fullname&country=$country&institution=&institution& from=$from&message=$message&wrong_code=true");
    exit;
}   
?>
<!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>E-Mail Sent</title>
<style type="text/css">
<!--
body,td,th {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 12px;
}
-->
</style></head>
 
<body>
Email sent. Thank you.<br />
<br />
Return to <a href="/">home page</a> ? 
</body>
</html>
 

Re: php email problem

Posted: Tue Feb 19, 2008 1:09 pm
by Christopher
Check the PHP manual page for the mail() function. They give a good example of exactly how you need to set the headers to get HTML emails to work. Or use SwiftMailer.

Re: php email problem

Posted: Tue Feb 19, 2008 1:17 pm
by plodos
this code is a little easy to understand...
but problem is same, mixing the HTML codes and Variables...
PHP manual has very difficult examples or source codes..
Have u any idea, for this code!!!!!

Code: Select all

 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<html>
<head>
</head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<body>
<?php
$name = "xxx";
$surname = "yyy";
$to="bbb@bbb.com";
$aut_email="xxx@xxx.com";
$headers = "From: $aut_email  \n";
 
$message= '
<table width="522" height="235" border="1">
  <tr>
    <td width="105" height="23" bgcolor="#CCCCCC">Name Surname </td>
    <td width="403" bgcolor="#CCCCCC">'.$name.' '.$surname.'</td>
  </tr>
</table>';
 
if(mail($to, $title,$message,$headers)) echo "send";
else "not send"
?>
</body>
</html>
 
 

Re: php email problem

Posted: Tue Feb 19, 2008 1:20 pm
by Christopher
You need to use double quotes or heredoc for your $message =.

Code: Select all

$message = "
...
";
// or 
$message = <<<HTML
...
HTML;

Re: php email problem

Posted: Tue Feb 19, 2008 1:36 pm
by plodos

Code: Select all

$message=<<<HTML
<table width="522" height="235" border="1">
  <tr>
    <td width="105" height="23" bgcolor="#CCCCCC">Name Surname </td>
    <td width="403" bgcolor="#CCCCCC">'.$name.'</td>
  </tr>
</table> HTML;
like that, but it is not working?