1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
|
<?php echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?".">"; ?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
<head>
<title>Contact</title>
<link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body>
<?php
function formulaire($name="",$email="",$subject="",$message="") {
?>
<div align="center">
<p> </p>
<form action="<?php echo $PHP_SELF ?>" method="post">
<table>
<tr><th colspan="2">Send an e-mail to <a href="http://www.moi.fr">Damien</a></th></tr>
<tr><td>Name</td><td><input type="text" name="name" size="68" value="<?php echo trim(htmlentities($name)) ?>" /></td></tr>
<tr><td>Email</td><td><input type="text" name="email" size="68" value="<?php echo trim(htmlentities($email)) ?>" /></td></tr>
<tr><td>Subject</td><td><input type="text" name="subject" size="68" value="<?php echo trim(htmlentities($subject)) ?>" /></td></tr>
<tr><td>Message</td><td><textarea name="message" rows="10" cols="70" wrap="virtual"><?php echo trim(htmlentities($message)) ?></textarea></td></tr>
<tr><td> </td><td><input type="submit" value="Send"/></td></tr>
</table>
</form>
<?php
}
if(!isset($name)) {formulaire();}
else {
$Vname=trim(htmlentities($_POST["name"]));
$Vemail=trim(htmlentities($_POST["email"]));
$Vsubject=trim(htmlentities($_POST["subject"]));
$Vmessage=trim(htmlentities($_POST["message"]));
$recipient='mon@email.fr';
$msg="Provenance : $HTTP_REFERER\n";
$msg.="Adresse IP : $REMOTE_ADDR,\n";
$msg.="Navigateur : $HTTP_USER_AGENT\n";
$msg.="Nom : $Vname\nE-mail : $Vemail\nMessage : $Vmessage\n";
if (empty($Vname) || empty($message) || empty($email) || empty($subject)) {
echo "<p>Missing fields !</p>";
$error=1;
}
if (!eregi("^[0-9a-z]([-_.]?[0-9a-z])*@[0-9a-z]([-_.]?[0-9a-z])*\\.[a-z]{2,4}$",$Vemail) && ($error<>1)){
echo "<p>Email is not valid.</p>";
$error=1;
}
if ($error==1) {
formulaire($name,$email,$subject,$msg);
}
else {
if (mail($recipient,$Vsubject,$msg)) {
echo "<p>Your message has been sent.</p>\n" ;
echo "Return to <a href=\"index.html\">homepage</a>";
}
else {
echo "<p>An error occured while sending your message.</p>\n";
}
}
}
?>
</div>
</body>
</html> |