Hi,
I am new to PHP and am having a problem with a form to email information collected from an html form. When I use the "GET" parameter, the information gets to the intended email. When I use "POST" the email returns with empty fields. Can someone describe the difference between "GET" and "POST" that would cause this? My client does not want a database on his site. Just information emailed to him from these forms. Also, I am concerned with security using "GET" where the information is shown in the URL.
Here is the code I am using with "GET" and it is working but I think "POST" is what I will need for securitiy reasons. Can you use "POST" without a database?
<?php
// variables
$customer_name = $_GET['customer_name'];
$from = $_GET['customer_email'];
$customer_phone = $_GET['customer_phone'];
$customer_comment = $_GET['customer_comment'];
//to and subject
$to = "ozzie@bclean.com";
$subject = "Customer Inquiry";
//message body
$message = '
<html>
<head>
</head>
<body>
<table width="90%" border="0" cellspacing="0" cellpadding="3">
<tr>
<td width="15%" align="left" valign="top">Name:</td>
<td align="left" valign="top"><b>'.$custome
r_name.'</
b></td>
</tr>
<tr>
<td width="15%" align="left" valign="top">Email Address:</td>
<td align="left" valign="top"><b>'.$from.'<
/b></td>
</tr>
<tr>
<td width="15%" align="left" valign="top">Phone Number:</td>
<td align="left" valign="top"><b>'.$custome
r_phone.'<
/b><br></t
d>
</tr>
<tr>
<td colspan="2"><h2>How may we be of assistance?</h2></td>
</tr>
<tr>
<td colspan="2"><p>'.$customer
_comment.'
</p></td>
</tr>
</table>
</body>
</html>
';
//make sure text wraps if it is to long
$message = wordwrap($message, 70);
//set html content type
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: ' .$from. "\r\n";
mail($to, $subject, $message, $headers);
?>
Start Free Trial