<?php
echo " <center>";
//BEGIN PROCESSING EMAIL
if ($_POST['name']){
//CHECK YO SEE IF REQUIED FIELDS ARE EMPTY
if(empty($_POST['name']) || empty($_POST['email'])){
//IF A REQUIRED FIELD IS EMPTY SHOW THIS TO USER
echo " <div class='plaintext'><br />Please fill out the form completly</div><br />";
}
//IF ALL FIELDS ARE FILLED OUT SEND THE MESSAGE INFORMATION
else{
$where_form_is="http".($HTTP_SERVER_VARS["HTTPS"]=="on"?"s":"")."://".$SERVER_NAME.strrev(strstr(strrev($PHP_SELF),"/"));
$message="Name: ".$name."
Email: ".$email."
Yahoo: ".$yahoo."
MSN: ".$msn."
Comments: ".$Comments."
";
$message = stripslashes($message);
//EDIT REQUIRED:::::::::::CHANGE [email protected] TO YOUR EMAIL ADDRESS
//EDIT REQUIRED:::::::::::CHANGE FROM: YOUR WEBSITE TO FROM: <WHAT YOU WANT>
mail("[email protected]","Contact Us Form Submitted",$message,"FROM: YOUR WEBSITE");
//END PROCESSING EMAIL
//BEGIN SHOWING WHAT THE USER SUBMITTED
echo " <div class='txtSession'>Thank you. You input this information.</div>";
echo " <table width=75%>";
echo " <tr>";
echo " <td><div class='txtSession'>Name:</div></td>";
echo " <td><div class='txtSession'>$name</div></td>";
echo " </tr><tr>";
echo " <td><div class='txtSession'>Email:</div></td>";
echo " <td><div class='txtSession'>$email</div></td>";
echo " </tr><tr>";
echo " <td><div class='txtSession'>Yahoo:</div></td>";
echo " <td><div class='txtSession'>$yahoo</div></td>";
echo " </tr><tr>";
echo " <td><div class='txtSession'>MSN:</div></td>";
echo " <td><div class='txtSession'>$msn</div></td>";
echo " </tr><tr>";
echo " <td><div class='txtSession'>Comments:</div></td>";
echo " <td><div class='txtSession'>$Comments</div></td>";
echo " </tr>";
echo " </table>";
//END SHOWING WHAT THE USER SUBMITTED
}
}
//BEGIN THE CONTACT FORM
echo " <br/><br/>";
echo " <form method='post' action='contactus.php' target='_self'>";
echo " <table width='75%' border='0'>";
echo " <tr>";
echo " <td><div class='txtSession'>Name *</div></td>";
echo " <td><input type='text' size='30' name='name' class='textbox'></td>";
echo " </tr><tr>";
echo " <td><div class='txtSession'>Email *</div></td>";
echo " <td><input type='text' size='30' name='email' class='textbox'></td>";
echo " </tr><tr>";
echo " <td><div class='txtSession'>Yahoo</div></td>";
echo " <td><input type='text' size='30' name='yahoo' class='textbox'></td>";
echo " </tr><tr>";
echo " <td><div class='txtSession'>MSN</div></td>";
echo " <td><input type='text' size='30' name='msn' class='textbox'></td>";
echo " </tr><tr>";
echo " <td><div class='txtSession'>Comments</div></td>";
echo " <td> </td>";
echo " </tr><tr>";
echo " <td colspan='2'><textarea cols='50' name='Comments' rows='5' class='textbox'>Give us your feedback, good or bad!</textarea></td>";
echo " </tr>";
echo " </table>";
echo " <div align='center'><input type='submit' value='Submit Form'> <input type='reset' value='Clear Form'></div>";
echo " </form>";
//END THE CONTACT FORM
echo " </center>";
?>
1 |<p>
2 | <?php
3 |
4 |$body_of_message= $_POST['message']. "\n";
5 |$body_of_message .= "Sent by " . $_POST['name'];
6 |$subject= "Message from the feedback form";
7 |
8 |if(mail("[email protected]",$subject,$body_of _message)) {
9 |echo "Your message was sent.";
10|} else {
11|echo "There was a problem.";
12|};
13|
14|?>
15|</p>
16|
if(mail("[email protected]",$subject,$body_of _message)) {you have a space in the middle of the variable name, "$body_of _message", before the second underscore. Delete it. :)
Please then show the results - this will print the contents of the $_POST array.<?php print_r($_POST); ?>