de Devorg le Ven 25 Avr 2008 12:33
Copiez le code et sauvez le dans un fichier form_to_email.php a la racine de votre ftp.
- Code: Tout sélectionner
<?
// Check, if submitted.
if($Submit){
/*
Send email to "webmaster@localhost".
If you want to send more than 1, use "," between the second, third,...
Ex. webmaster@localhost, me@domain.com, you@domain.com, ...
*/
$to="webmaster@localhost";
$subject="Contact information from website.";
// Get time from server.
$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
";
// Send email.
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>
<? } ?>