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 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176
| <?php
$submit = $_POST['submit'];
$nom = $_POST['nom'];
$email = $_POST['email'];
$area = $_POST['area'];
$exchange = $_POST['exchange'];
$number = $_POST['number'];
$projet = ($_POST['projet']);
?>
<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Formulaire de demande de projet</title>
<style>
input {
font-family: Tahoma;
font-size: 8pt;
}
.label {
width:50px;
}
textarea {
width: 200px;
font-family: Tahoma;
font-size: 8pt;
}
body {
font-family: Tahoma;
font-size: 8pt;
}
.error {
font-family: Tahoma;
font-size: 8pt;
color: red;
margin-left: 50px;
display:none;
}
</style>
<script type='text/javascript'>
function formValidator(){
fvalid=false;
message+='Please enter a value in Field 1<br>';
// Make quick references to our fields
var nom = document.getElementById('nom');
var area = document.getElementById('area');
var exchange = document.getElementById('exchange');
var number = document.getElementById('number');
var email = document.getElementById('email');
var projet = document.getElementById('projet');
// Check each input in the order that it appears in the form!
if(isAlphabet(nom, "S.v.p, veuillez entrer seulement que des lettres pour votre nom")){
if(isNumeric(area, "S.v.p, veuillez entrer un format valide pour le numéro de téléphone")){
if(isNumeric(exchange, "S.v.p, veuillez entrer un format valide pour le numéro de téléphone")){
if(isNumeric(number, "S.v.p, veuillez entrer un format valide pour le numéro de téléphone")){
if(emailValidator(email, "S.v.p, veuillez entrer une adresse de courriel valide")){
if(isEmpty(projet, "S.v.p, veuillez entrer la description de votre projet")){
return true;
}
}
}
}
}
}
return false;
}
function isEmpty(elem, helperMsg){
if(elem.value.length == 0){
alert(helperMsg);
elem.focus(); // set the focus to this input
return false;
}
return true;
}
function isNumeric(elem, helperMsg){
var numericExpression = /^[0-9]+$/;
if(elem.value.match(numericExpression)){
return true;
}else{
alert(helperMsg);
elem.focus();
return false;
}
}
function isAlphabet(elem, helperMsg){
var alphaExp = /^[a-zA-Z]+$/;
if(elem.value.match(alphaExp)){
return true;
}else{
fvalid=false;
message+='Please enter a value in Field 2<br>';
elem.focus();
}
}
function emailValidator(elem, helperMsg){
var emailExp = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/;
if(elem.value.match(emailExp)){
return true;
}else{
alert(helperMsg);
elem.focus();
return false;
}
}
</script>
</head>
<body>
<?php if( isset($submit) ) {
$subject = "Projet du client $nom";
$htmlmessage = "
De: $nom<br />
Courriel: $email<br />
Téléphone: $area-$exchange-$number<br />
Projet: $projet
";
$headers = "From: $nom <$email>\r\n";
$headers .= "Content-Type: text/html;\r\n charset=\"iso-8859-1\"\r\n";
$headers .= "Reply-To: $email\r\n";
mail("@hotmail.com", $subject, $htmlmessage, $headers);
echo "<p>Merci! Votre message à été envoyé avec succès.</p>";
} else {
?>
<form method='post' onsubmit='return formValidator()' action='<?php $_SERVER['PHP_SELF'];?>' name='form'>
<table width="387" border="0">
<tr>
<td width="177">Nom :</td>
<td width="200"><input name='nom' type='text' id='nom'/></td>
</tr>
<tr>
<td>Téléphone (000-000-0000) :</td>
<td><input name='area' type='text' id='area' size="3" maxlength="3"/>
-
<input name='exchange' type='text' id='exchange' size="3" maxlength="3"/>
-
<input name='number' type='text' id='number' size="4" maxlength="4"/></td>
</tr>
<tr>
<td>Courriel (adresse@email.com) :</td>
<td><input name='email' type='text' id='email'/></td>
</tr>
<tr>
<td>Description du projet:</td>
<td><textarea name='projet' cols="25" rows="10" id="projet"></textarea></td>
</tr>
<tr>
<td> </td>
<td><div align="right">
<input type="submit" value="Send" name="submit" />
</div></td>
</tr>
</table>
<p> </p>
</form>
<?php
}
?>
</body>
</html> |
Partager