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
| <?php require_once('Connections/cnn.php'); ?>
<?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 agenda (id, date_deb, date_fin, date_expiration, titre, descriptif, adresse, photo) VALUES (%s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($HTTP_POST_VARS['id'], "int"),
GetSQLValueString($HTTP_POST_VARS['date_deb'], "date"),
GetSQLValueString($HTTP_POST_VARS['date_fin'], "date"),
GetSQLValueString($HTTP_POST_VARS['date_expiration'], "date"),
GetSQLValueString($HTTP_POST_VARS['titre'], "text"),
GetSQLValueString($HTTP_POST_VARS['descriptif'], "text"),
GetSQLValueString($HTTP_POST_VARS['adresse'], "text"),
GetSQLValueString($HTTP_POST_VARS['photo'], "text"));
mysql_select_db($database_cnn, $cnn);
$Result1 = mysql_query($insertSQL, $cnn) or die(mysql_error());
$insertGoTo = "affichage.php";
if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $HTTP_SERVER_VARS['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
mysql_select_db($database_cnn, $cnn);
$query_Recordset1 = "SELECT * FROM agenda";
$Recordset1 = mysql_query($query_Recordset1, $cnn) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?>
<html>
<head>
<title>Document sans titre</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<form method="post" name="form1" action="<?php echo $editFormAction; ?>">
<table align="center">
<tr valign="baseline">
<td nowrap align="right">Date_deb:</td>
<td><input name="date_deb" type="text" value="<? echo date('d-m-Y',time()) ?>" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Date_fin:</td>
<td><input type="text" name="date_fin" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Date_expiration:</td>
<td><input type="text" name="date_expiration" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Titre:</td>
<td><input type="text" name="titre" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Descriptif:</td>
<td><input type="text" name="descriptif" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Adresse:</td>
<td><input type="text" name="adresse" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Photo:</td>
<td><input name="photo" type="file"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right"> </td>
<td><input type="submit" value="Insérer l'enregistrement"></td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="form1">
</form>
<p> </p>
</body>
</html>
<?php
mysql_free_result($Recordset1);
?> |
Partager