I am in the process of learning php and decided to try some out. The following is a code for an email form. This will let users on your site email you while on your site with feedback/ideas e.t.c. So here we go!
Please create a file called mail_form.php. If you give the file a different name, please change the file name in the code
CODE
<html>
<body>
<form action="MAILTO:Youremail@email.com" method="post">
<table border="0" bgcolor="grey" cellspacing="6">
<tr><td>Name</td><td><input type="text" size="30" name="name" value="name">
</td>
</tr>
<tr><td>Email address</td><td><input type="text" size="30" name="email" value="Email">
</td>
</tr>
<tr><td valign="top">Messsage</td><td><textarea name="comments" rows="10" cols="30">
</textarea>
</td>
</tr>
<tr><td> </td><td><input type="submit" value="Send">
</table>
</form>
</body>
</html>
<body>
<form action="MAILTO:Youremail@email.com" method="post">
<table border="0" bgcolor="grey" cellspacing="6">
<tr><td>Name</td><td><input type="text" size="30" name="name" value="name">
</td>
</tr>
<tr><td>Email address</td><td><input type="text" size="30" name="email" value="Email">
</td>
</tr>
<tr><td valign="top">Messsage</td><td><textarea name="comments" rows="10" cols="30">
</textarea>
</td>
</tr>
<tr><td> </td><td><input type="submit" value="Send">
</table>
</form>
</body>
</html>
OR
CODE
<html>
<body>
<form>
<table border="0" bgcolor="F5F5F5" cellspacing="6">
<tr><td>Name:</td><td><input type="text" size="30" name="name" value="Your Name">
</td>
</tr>
<tr><td>Email Address:</td><td><input type="text" size="30" name="email" value="Your Email">
</td>
</tr>
<tr><td valign="top">Messsage:</td><td><textarea name="message" value="Type your message here!" rows="10" cols="30">
</textarea>
</td>
</tr>
<tr><td> </td><td><input type="submit" value="Send">
</table>
</form>
<?php
{
$name = $_REQUEST['name'];
$email = $_REQUEST['email'];
$message = $_REQUEST['message'];
mail( "youremail@email.com", "Subject: $message",
$message, "From: $email" );
echo "Thanks, your message has been sent.";
}
?>
</body>
</html>
<body>
<form>
<table border="0" bgcolor="F5F5F5" cellspacing="6">
<tr><td>Name:</td><td><input type="text" size="30" name="name" value="Your Name">
</td>
</tr>
<tr><td>Email Address:</td><td><input type="text" size="30" name="email" value="Your Email">
</td>
</tr>
<tr><td valign="top">Messsage:</td><td><textarea name="message" value="Type your message here!" rows="10" cols="30">
</textarea>
</td>
</tr>
<tr><td> </td><td><input type="submit" value="Send">
</table>
</form>
<?php
{
$name = $_REQUEST['name'];
$email = $_REQUEST['email'];
$message = $_REQUEST['message'];
mail( "youremail@email.com", "Subject: $message",
$message, "From: $email" );
echo "Thanks, your message has been sent.";
}
?>
</body>
</html>
And there you go! You now have a email form in your website
Preview
