I know I have another of these posted on my blog however that one assumes that php global settings is OFF and many servers have it set to ON. So here is one that should work regardless of your server settings. To see an example of this working, just click on the contact page of my website in the links above.
Code:
<html>
<body>
<?php
//if submit button pressed
if(isset($_POST[‘submit’])){
//sending to my email
$name = $_POST[‘name’];
$email = $_POST[’email’];
$comments = $_POST[‘comments’];
$subject = $_POST[‘subject’];
$sql = “‘$name’, ‘$email’, ‘$comments'”;
$em = “‘$subject'”;
mail(‘enterYourEmailAddressHere’, $em, $sql);
echo(“<p>You message has been sent!” . “</p>”);
}
?>
<form name=”form1″ id=”form1″ method=”post” action=”<?=$PHP_SELF?>”>
<p align=”left”><strong>Name:</strong>
<input type=”text” name=”name” />
</p>
<p align=”left”> </p>
<p align=”left”><strong>Email:</strong>
<input type=”text” name=”email” />
</p>
<p align=”left”> </p>
<p align=”left”><strong>Subject:</strong>
<input type=”text” name=”subject” />
</p>
<p align=”left”> </p>
<p align=”left”><strong>Message:</strong>
<textarea name=”comments” cols=”60″ rows=”3″></textarea>
</p>
<p align=”left”>
<input name=”submit” type=”submit” id=”submit” value=”submit” />
<input type=”reset” name=”Submit2″ value=”Reset” />
</p>
</form>
</body>
</html>