0

Hi, I am having problem in receiving e-mail through contact form.


contact_us.php

<h2>Contact Us</h2>
<br /><br />
      
<form action="send_email1.php" method="POST">      
<table border="0" cellpadding="2">
<tr>	
    <td>Nama Lengkap: </td>
 	<td><input name="nama" type="text" value="" size="30" /></td>
</tr>
<tr>    
    <td>E-mail: </td>
	<td><input name="email" type="text" value="" size="20" /></td>
</tr>    
<tr>
	<td>Nomor Telepon: </td>
    <td><input name="telp" type="text" value="" size="15" /></td>
</tr>    
<tr>
	<td>Pilih Subjek : </td>
    <td><select name="subjek"><option value=Additive selected>Additive</option>
    <option value=Air Freshener>Air Freshener</option>
    <option value=Lainnya>Lainnya</option>    
    </td>
</tr>
<tr>
	<td>Pesan Anda  : </td>
	<td><textarea name="comments" cols=30 rows=6></textarea></td>
</tr>
<tr>
	<td></td>
    <td><input name="kirim_pesan" type="submit" value="Kirim Pesan" /> 
</table>
</form>      
</div>

send_email1.php

<?
	$name 		= $_REQUEST['nama'];
	$email 		= $_REQUEST['email'];
	$telp 		= $_REQUEST['telepon'];
	$subjek 	= $_REQUEST['subjek'];
	$comments 	= $_REQUEST['comments'];
	
	function HtmlSecure() {
		$_GET = array_map('htmlspecialchars' , $_GET);
		$_POST = array_map('htmlspecialchars' , $_POST);
		$_COOKIE = array_map('htmlspecialchars' , $_COOKIE);
	}
	
	HtmlSecure();

	$to = "david_yg20@yahoo.com";
	$subject = "Masterlink Contact";
	$from = $email;
	$body = "A visitor at masterlink.co.id has sent the following information\n
	Nama			: $name
	Email			: $email
	Telp			: $telp
	Pesan			: $comments";
	
	if (mail($to, $subject, $body,"From: $email")) 
	{
	   //header("location:http://www.masterlink.co.id/cgoods/contact_us.php");
	} 
	
	else
	{
	   //header("location:http://www.masterlink.co.id/cgoods/fail_notice.php");
	}

?>

Please cek my code. Why it doesn't work?

2
Contributors
1
Reply
2
Views
5 Years
Discussion Span
Last Post by simplypixie
0

This is wrong:

mail($to, $subject, $body,"From: $email")

You need headers and then change the above:

$headers = "From: <$from>\r\n";
			$headers.= "Reply-To: youremailaddresshere\r\n";
			$headers.= 'Content-type: text/plain;charset="iso-8859-1"';

mail($to, $subject, $body, $headers);
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.