PHP Automated Email Tutorial
First, we need a new html page preferably called "form.html". Add the following code:
<form method="POST" action="mailer.php">
Email
<input type="text" name="email" size="19">
<input type="submit" value="Submit" name="submit">
</form>
Now that we have that, we go on to php.
Add this code to "Mailer.php" in the same direcorty:
<?php
if(isset($_POST['submit'])) {
$ip=$_SERVER['REMOTE_ADDR'];
$email_field = $_POST['email'];
$subjecte = "Testr";
$bodye = "Hello, $name-field!\n You should have $coin_field in your club penguin account";
$body = "THIS IS THE MESSAGE HERE ";
echo "An email has been sent to $email_field.";
mail($email_field, $subjecte, $bodye);
} else {
echo "HEY! You refreshed the page, didn't you? Well, YOU CAN'T DO THAT. Whenever you refresh me, YOU BRAINWjavascript:validForm('save');
SaveASH ME!!";
}
?>
But, all this does is send an email saying "Your Message Here".
We want some dynamic stuff in the email, right?
Edit the form html file to:
<form method="POST" action="mailer.php">
Name
<input type="text" name="name" size="19">
Email
<input type="text" name="email" size="19">
<input type="submit" value="Submit" name="submit">
</form>
And the mailer.php to:
<?php
if(isset($_POST['submit'])) {
$ip=$_SERVER['REMOTE_ADDR'];
$email_field = $_POST['email'];
$subjecte = "Test";
$name = $_post['name'];
$body = "Hello $name, \n your message here ";
echo "An email has been sent to $email_field.";
mail($email, $subjecte, $body);
} else {
echo "HEY! You refreshed the page, didn't you? Well, YOU CAN'T DO THAT. Whenever you refresh me, YOU BRAINWjavascript:validForm('save');
SaveASH ME!!";
}
?>
This now send an email saying " Hello [name],
Your Message Here"
Thank you for veiwing this tutorial!