P2P | IT Discussions Forum

Full Version: email using php
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
As many of you have seen you can send emails using php but a lot of people dont know how, so i would like to tell you all ..


PHP Code:
<?
if($_POST[submit]){ // Checks to see if the form has been submitted or not
$to = "YOUREMAIL@YOURSITE.COM"; // Your Email Address
$subject = $_POST['subject']; // Gets the fields from the form
$message = $_POST['message'];
if($subject==NULL|$message==NULL) { // Checks to see if the fields are left blank and if so it display the message
die("Sorry, but one of the fields was left blank. Please Return To The Form");
}
$mailsend = mail($to,$subject,$message); // Puts the information into order and then sends it
{
header("Location: ?message=Thank you"); // Redirects the page back to contact.php and then displays a message
}
}
?><form method="POST" action="submit.php">
<p><label for="fp2">Subject:

</label>
<input type="text" name="subject" size="20" id="fp2">

<label for="fp1">Message:

</label>
<textarea rows="6" name="message" cols="16" id="fp1"></textarea>

<input type="submit" value="Submit" name="submit"><input type="reset" value="Reset" name="B2"></p>
</form>
<? echo $message ?>
Reference URL's