Forum Moderators: coopster
<html>
<head>
<title>Contact Form</title>
<body>
<?php
if ($_SERVER['REQUEST_METHOD']!= 'POST'){
$me = $_SERVER['PHP_SELF'];
?>
<form name="form1" method="post"
action="<?php echo $me;?>">
<table border="0" cellspacing="0" cellpadding="2">
<tr>
<td>Name:</td>
<td><input type="text" name="Name"></td>
</tr>
<tr>
<td>Subject</td>
<td><input type="text" name="Subject"></td>
</tr>
<tr>
<td>Address</td>
<td><input type="text" name="address"></td>
</tr>
<tr>
<td>City</td>
<td><input type="text" name="city"></td>
</tr>
<tr>
<td>Province</td>
<td><input type="text" name="province"></td>
</tr>
<tr>
<td>Postal Code</td>
<td><input type="text" name="postalcode"></td>
</tr>
<tr>
<td>Stock Number</td>
<td><input type="text" name="stocknumber"></td>
</tr>
<tr>
<td valign="top">Message:</td>
<td><textarea name="MsgBody"></textarea></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="Submit"
value="Send"></td>
</tr>
</table>
</form>
<?php
} else {
error_reporting(0);
$recipient = 'example@yahoo.com';
$subject = stripslashes($_POST['Subject']);
$from = stripslashes($_POST['Name']);
$add = stripslashes($_POST['address']);
$city = stripslashes($_POST['city']);
$province = stripslashes($_POST['province']);
$postalcode = stripslashes($_POST['postalcode']);
$stocknumber = stripslashes($_POST['stocknumber']);
$msg = "Message from: $from\n\n$stocknumber\n\n$add\n\n$city\n\n$province\n\n$postalcode\n\n$stocknumber".stripslashes($_POST['MsgBody']);
if (mail($recipient, $subject, $msg))
echo nl2br("<b>Message Sent:</b>
To: $recipient
Subject: $subject
Message: Thank your submission.");
else
echo "Message failed to send";
}
?>
</body>
</html>
You may want to try something like this to get a different sender:
$from = "From: CoolDude <cooldude@example.com>"; then
mail($recipient, $subject, $msg, $from) See the mail section of the manual [us2.php.net] for more optional headers.
[edited by: StupidScript at 11:21 pm (utc) on Aug. 9, 2005]
Try adding header info:
<?php
} else {
error_reporting(0);
$recipient = 'example@yahoo.com';
$subject = stripslashes($_POST['Subject']);
$from = stripslashes($_POST['Name']);
$add = stripslashes($_POST['address']);
$city = stripslashes($_POST['city']);
$province = stripslashes($_POST['province']);
$postalcode = stripslashes($_POST['postalcode']);
$stocknumber = stripslashes($_POST['stocknumber']);
$msg = "Message from: $from\n\n$stocknumber\n\n$add\n\n$city\n\n$province\n\n$postalcode\n\n$stocknumber".stripslashes($_POST['MsgBody']);
$headers = "From: 'Example Business'<example@yahoo.com>\r\n" . "to: '$from' <$recipient>" . "\r\n" . "Reply-To: 'Example Business'<example@yahoo.com>\r\n" . 'X-Mailer: PHP/' . phpversion();
if (mail($recipient, $subject, $msg, $headers))
echo nl2br("<b>Message Sent:</b>
To: $recipient
Subject: $subject
Message: Thank your submission.");
else
echo "Message failed to send";
}
?>