|
Contact form on your sites to email
|
|
|
|
|
Friday, 20 March 2009
|
HTML clipboard
You can apply this tutorial for your contact form on your sites. This tutorial
shows you in 1 file with a normal contact information form. When you submit,
this file will be sent an email immediately to the target email including in
codes.
form_to_email.php
Source Code :
<?
if($Submit){
$to="webmaster@localhost";
$subject="Contact information from website.";
$time=date("d/m/Y");
$mail_from="From:$email n";
$mail_from .="Content-Type: text/html; charset=utf-8 n";
$message="
Contact on : $time<br>
Name : $name<br>
Email : $email<br>
Comment : $comment
";
mail($to,$subject,$message,$mail_from);
echo "Your contact information has been sent";
}else{
// Do following codes if not found "Submit" value.(Not submitted)
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<form action="<? echo $PHP_SELF; ?>" method="post"
name="form" id="form">
<table>
<tr>
<td align="right">Your name : </td>
<td><input name="name" type="text" id="name" /></td>
</tr>
<tr>
<td align="right">Your Email : </td>
<td><input name="email" type="text" id="email" /></td>
</tr>
<tr>
<td align="right" valign="top">Comment/ Request : </td>
<td><textarea name="comment" cols="60" rows="5" id="comment"></textarea></td>
</tr>
</table>
<input type="submit" name="Submit" value="Submit Form" />
</form>
</body>
</html>
<? } ?>
- Copy this code and save as form_to_email.php to your root
folder, open this file by browse to http://localhost/form_to_email.php.
- Fill in all text fields and click "Submit" button.
- Open your email client program to recieve email.
|