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
| <?php require_once('../Connections/root.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($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 = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO calendrier (jour, mois, annee, evenement)
VALUES ('jour', 'mois', 'annee', 'evenement'),
('jour2', 'mois', 'annee', 'evenement2'),
('jour3', 'mois', 'annee', 'evenement3'),
('jour4', 'mois', 'annee', 'evenement4'),
('jour5', 'mois', 'annee', 'evenement5'),
('jour6', 'mois', 'annee', 'evenement6')",
GetSQLValueString($_POST['jour'], "date"),
GetSQLValueString($_POST['mois'], "date"),
GetSQLValueString($_POST['annee'], "date"),
GetSQLValueString($_POST['evenement'], "text"));
mysql_select_db($database_root, $root);
$Result1 = mysql_query($insertSQL, $root) or die(mysql_error());
$insertGoTo = "ajouts des nouvelles pour l'agenda effectué.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
?>
Voici mon formulaire simplifié:
<td><label for="mois"></label>
<select name="mois" id="mois">
<option value="1" selected="selected">janvier</option>
<option value="2">février</option>
<option value="3">mars</option>
<option value="4">avril</option>
<option value="5">mai</option>
<option value="6">juin</option>
<option value="7">juillet</option>
<option value="8">août</option>
<option value="9">septembre</option>
<option value="10">octobre</option>
<option value="11">novembre</option>
<option value="12">décembre</option>
</select></td>
<td><label for="label">Année:</label></td>
<td><label for="annee"></label>
<select name="annee" id="annee">
<option value="2008" selected="selected">2008</option>
<option value="2009">2009</option>
<option value="2010">2010</option>
<option value="2011">2011</option>
</select></td>
</tr>
<tr>
<td><div align="center">Jour(s):</div></td>
<td>Evénement(s):</td>
</tr>
<tr>
<td><label for="jour"></label>
<div align="center">
<select name="jour" id="jour">
<option value="1" selected="selected">1</option> etc
</select>
</div></td>
<td colspan="4"><label for="evenement"></label>
<textarea name="evenement" cols="130" rows="5" id="evenement"></textarea></td>
</tr>
<tr>
<td><div align="center">
<select name="jour2" id="jour2">
<option value="1" selected="selected">1</option> etc
</select>
</div></td>
<td> </td>
<td><textarea name="evenement2" cols="130" rows="5" id="evenement2"></textarea></td>
</tr> et ainsi de suite jusquà jour6 et evenement6
<td><label for="envoi"></label>
<input type="submit" name="envoi" id="envoi" value="ENVOYER LES INFORMATIONS POUR L'AGENDA" /></td>
</table>
<input type="hidden" name="MM_insert" value="form1" />
</form> |
Partager