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
| <?php
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
$editFormAction = $HTTP_SERVER_VARS['PHP_SELF'];
if (isset($HTTP_SERVER_VARS['QUERY_STRING']))
{
$editFormAction .= "?" . $HTTP_SERVER_VARS['QUERY_STRING'];
}
if ((isset($HTTP_POST_VARS["MM_insert"])) && ($HTTP_POST_VARS["MM_insert"] == "form1"))
{
$insertSQL = sprintf("INSERT INTO ABONNES (Nom, Prénom, age, email, Filière, Cell, Date) VALUES (%s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($HTTP_POST_VARS['Nom'], "text"),
GetSQLValueString($HTTP_POST_VARS['Prénom'], "text"),
GetSQLValueString($HTTP_POST_VARS['age'], "int"),
GetSQLValueString($HTTP_POST_VARS['email'], "text"),
GetSQLValueString($HTTP_POST_VARS['Filière'], "text"),
GetSQLValueString($HTTP_POST_VARS['Cell'], "int"),
GetSQLValueString($HTTP_POST_VARS['Date'], "date"));
mysql_select_db($database_lietesteur, $lietesteur);
$Result1 = mysql_query($insertSQL, $lietesteur) or die(mysql_error());
$insertGoTo = "http://www.abidjan.net"; // page à afficher après validation du formulaire
if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $HTTP_SERVER_VARS['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
?>
<html>
<head>
<title>formulaire</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
.Style1 {
color: #0000FF;
font-weight: bold;
}
.Style2 {font-size: 18px}
-->
</style>
<SCRIPT language="JavaScript">
<!--
function ControleForm()
{
if(document.form1.Nom.value=='')
{
alert('Le champ Nom ne peut pas rester vide !');
document.form1.Nom.focus();
}
else if(document.form1.Prénom.value=='')
{
alert('Le champ Prénom ne peut être vide !');
document.form1.Prénom.focus();
}
else if(document.form1.email.value=='')
{
alert('Le champ E mail ne peut être vide !');
document.form1.email.focus();
}
else if(!document.form1.email.value.match ("[-\./w]*@[/w]*\.[/w]*"))
{
alert('Le champ E mail doit être bien rempli !');
document.form1.email.focus();
}
else if(document.form1.Filière.value=='')
{
alert('Le champ Filière ne peut être vide !');
document.form1.Filière.focus();
}
else if(document.form1.Cell.value=='')
{
alert('Le champ Mobile ne peut être vide !');
document.form1.Cell.focus();
}
else if(isNaN(document.form1.Cell.value))
{
alert('Le champ Mobile ne peut être que numérique !');
document.form1.Cell.focus();
}
else
{
document.form1.method = "POST";
document.form1.action = "<?php echo $editFormAction; ?>" ; (Je pense que c'est a ce niveau que se trouve le probleme)
document.form1.submit();
}
}
//-->
</script>
</head>
<body>
<p> </p>
<p> </p>
<p> </p>
<p align="center" class="Style1 Style2"><u><strong>REMPLISSEZ CE FORMULAIRE</strong>
</u></p>
<p align="center" class="Style1 Style2"> </p>
<form method="post" name="form1" action="<?php echo $editFormAction; ?>">
<table align="center">
<!--DWLayoutTable-->
<tr valign="baseline">
<td nowrap align="right"><span class="Style1">Nom:</span></td>
<td><input type="text" name="Nom" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right"><span class="Style1">Prénom:</span></td>
<td><input type="text" name="Prénom" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right"><span class="Style1">Age:</span></td>
<td><select name="age">
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
<option value="24">24</option>
<option value="25">25</option>
<option value="26">26</option>
<option value="27">27</option>
<option value="28">28</option>
<option value="29">29</option>
<option value="30">30</option>
<option value="31">31</option>
<option value="32">32</option>
<option value="33">33</option>
<option value="34">34</option>
<option value="35">35</option>
</select></td>
</tr>
<tr valign="baseline">
<td nowrap align="right"><span class="Style1">E_mail:</span></td>
<td><input type="text" name="email" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right"><span class="Style1">Filière:</span></td>
<td><input type="text" name="Filière" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right"><span class="Style1">Mobile:</span></td>
<td><input name="Cell" type="text" value="00000000" size="32" maxlength="8"></td>
</tr>
<tr valign="baseline">
<td> </td>
<td><input name="Date" type="hidden" <?php echo 'value= " '.date('Y/m/d').' " ';?> ></td>
</tr>
<tr valign="baseline">
<td nowrap align="right"> </td>
<td><div align="center">
<input name="submit" type="button" class="Style1" value="ENVOYER" onClick="ControleForm();">
</div></td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="form1">
</form>
<p> </p>
</body>
</html> |
Partager