Formulaire de contact
Vous pouvez faire une page avec un formulaire de contact...
Il suffit de créer un extrait (snippet) qui utilise le code suivant.
<?php
// ----------------------------------------------------------------------------- //
// ------------------ Original script : http://www.mikeadev.net/---------------- //
// ----------------------------------------------------------------------------- //
// ----- Configuration
$receiver = Setting::get('admin_email'); // Admin Wolf Email.
$v_w = "Verification word"; // Write a word for the user to write, in order to unable bots to send emails.
// Examples: 2 + 2 = ?? then the v.w. shall be 4... or what color is the sky ??
// answer shall be blue, ect... :)
$yoursitename = Setting::get('admin_title'); // Your site name.
$homepage = URL_PUBLIC; // Your Website's main Page.
$url_2_contactf = "http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; // URL to contact form
$field_size = 30; // Chose the size you want the fields to be. Default 30.
$textarea_cols = 30; // Chose how many columns you want the text area to have. Default 30.
$textarea_row = 10; // Chose how many rows you want the text area to have. Default 10.
// ----- Custom Error Messages
$er_name = 'Enter your name please!'; // Enter your name
$er_email = 'Your email is invalid!'; // Email is invalid or empty
$er_email_miss = 'The email field was left empty!'; // Email field is empty
$er_sub = 'There is no subject!'; // There is No Subject
$er_msg = 'Please enter a message!'; // Enter a Message
$er_vw = 'Please enter a The Verification word!!'; // Enter Verification Word
$er_wvw = 'Wrong Verification Word!!'; // Wrong Verification Word
// ----- Styling
$tag_b4_message = '>>'; // The symbol before the error message. -, », >, *, ^ anything.
$tag_bitwin_er_msg_b4 = '<strong>'; // Tag before the message, you can put there span or p or div with some personal styling.
$tag_bitwin_er_msg_af = '</strong><br />';// Tag after the message, you can put there span or p or div with some personal styling.
// ----------------------------------------------------------------------------- //
// ------------------ DO NOT EDIT BELLOW THIS ---------------------------------- //
// ----------------------------------------------------------------------------- //
$acfv = '4.0.1'; // Version. Don't edit
if(isset($_POST['send']))
{
$name = htmlspecialchars(strip_tags($_POST['name']));
$url = htmlspecialchars(strip_tags($_POST['url']));
$email = htmlspecialchars(strip_tags($_POST['email']));
$subject = htmlspecialchars(strip_tags($_POST['subject']));
$msg = htmlspecialchars(strip_tags($_POST['msg']));
$vword = htmlspecialchars(strip_tags($_POST['vword']));
$ip = $_SERVER['REMOTE_ADDR'];
// ----- CHECK IF EMAIL IS VALID
function CheckMail($email)
{
if(eregi("^[0-9a-z]([-_.]?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])*\.[a-z]{2,4}$", $email))
return true;
else
return false;
}
// ----------------------------------------------------------------------------- //
// ------------------ CHECK IF EMAIL IS VALID ---------------------------------- //
// ----------------------------------------------------------------------------- //
// ----- Chek if the form has been filled
if(CheckMail($email) != true)
echo $tag_b4_message." ".$tag_bitwin_er_msg_b4." ".$er_email." ".$tag_bitwin_er_msg_af;
if(empty($email))
echo $tag_b4_message." ".$tag_bitwin_er_msg_b4."".$er_email_miss."".$tag_bitwin_er_msg_af;
if(empty($name))
echo $tag_b4_message." ".$tag_bitwin_er_msg_b4." ".$er_name." ".$tag_bitwin_er_msg_af;
if(empty($subject))
echo $tag_b4_message." ".$tag_bitwin_er_msg_b4." ".$er_sub." ".$tag_bitwin_er_msg_af;
if(empty($msg))
echo $tag_b4_message." ".$tag_bitwin_er_msg_b4." ".$er_msg." ".$tag_bitwin_er_msg_af;
if(empty($vword))
echo $tag_b4_message." ".$tag_bitwin_er_msg_b4." ".$er_vw." ".$tag_bitwin_er_msg_af;
if($vword != $v_w)
echo $tag_b4_message." ".$tag_bitwin_er_msg_b4." ".$er_wvw." ".$tag_bitwin_er_msg_af;
// ----- If they are not empty
if(!empty($name) && !empty($email) && !empty($subject) && !empty($msg) && !empty($vword) && CheckMail($email) == true)
{
if($vword == $v_w)
{
$headers .= "From: ".$email."";
// ----- We store the message in a variable
$messageproper =
"From: $name - $email \n" .
"------------------------- $yoursitename -------------------------\n\n" .
"Name: $name\n" .
"Subject: $subject\n" .
"Site Url: $url\n" .
"Email: $email\n\n" .
"Message: $msg\n\n" .
"Sender Ip: $ip" .
"\n------------------------------------------------------------\n";
$sent_email = mail("$receiver", $yoursitename. " - " .$subject, $messageproper, "From: $name <$email>");
if($sent_email)
{
echo '<blockquote> Thank You <strong>' . $name . '</strong>, your message was sent!! <br />
And for security reasons, your IP was recorded <strong> IP: ' .$ip .'</strong><br />
Please wait.... redirecting... :)
<script language=javascript>
setTimeout("location.href=\''.$homepage.'\'", 3000);
</script>
</blockquote>';
}
}
}
}
else
{
?>
<!-- EDIT BELLOW -->
<form method="post" action="<?php echo $url_2_contactf; ?>"><br />
<label for="name">Name</label><br />
<input type="text" name="name" id="name" size="<?php echo $field_size; ?>" /><br />
<label for="subject">Subject</label><br />
<input type="text" name="subject" id="subject" size="<?php echo $field_size; ?>" /><br />
<label for="url">Website URL</label><br />
<input type="text" name="url" id="url" size="<?php echo $field_size; ?>" /><br />
<label for="email">Email Address</label><br />
<input type="text" name="email" id="email" size="<?php echo $field_size; ?>" /><br />
<label for="msg">Message</label><br />
<textarea name="msg" id="msn" rows="<?php echo $textarea_row; ?>" cols="<?php echo $textarea_cols; ?>"></textarea><br />
<label for="vword"><acronym title="Spring">Verification Word</acronym></label><br />
<input type="text" name="vword" id="vword" size="<?php echo $field_size; ?>" /><br />
<input type="submit" name="send" value="Send Email!" /> <input type="reset" value="Reset Form!" />
</form>
<!-- EDIT ABOVE -->
<?php
}
?>
