<form method="post" action="sendmail.php"> Email: <input name="email" type="text" /><br /> Message:<br /> <textarea name="message" rows="15" cols="40"> </textarea><br /> <input type="submit" /> </form>Save it as feedback.html
open a clean window of notepad and enter the following code
<? $email = $_REQUEST['email']; $message = $_REQUEST['message']; mail( "email address", "subject text", $message, "From: $email" ); header( "Location:url" ); ?>Save this as sendmail.php.
Now lets break the code down starting with feedback.php.
<form method="post" action="sendmail.php">This tells the browser that it will pin the user submited contents of this form to sendmail.php
Email: ,<input name="email" type="text" /><br />
This is the code for a text input box called email. The same goes for
Message:<br /> <textarea name="message" rows="15" cols="40"></textarea>
<input type="submit" />This tells the browser to run the script and send the contents to sendmail.php.
Now onto sendmail.php
$email = $_REQUEST['email']; $message = $_REQUEST['message'];This is where the email address and message are sent and stored temperarly. the text inside ['text'] is the field name in feedback.html
mail("email address", "subject text",the word mail at the begining tells the server to send the form results to email address with the subject subject text. You will want to change these to your own.
$message, "From: $email" );this part of the code tells the php server what to include in the email. The $ message will make the server look at this line of code and include it in the body of the message:
$message = $_REQUEST['message'];the "From: $email" tells the server to include this line of code in the from section:
$message = $_REQUEST['email'];Then the code below tells the browser to send the client to another website like a thank you page or something.
header("Location:url" );you will want to change the url to the location of your thank you page or what ever you want. If you want to learn more about php url redirects visit my other post here. That topic is on how to create a url redirect page that used a command from the address bar to determin where to send you.
Any feedback on this lesson is welcome. Please let me know.