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
| $MM_fl="MM_insert";
if (isset($_POST[$MM_fl])) {
$MM_dupKey="page400.php";
if (isset($_SERVER['QUERY_STRING'])) {
$MM_dupKey .= (strpos($MM_dupKey, '?')) ? "&" : "?";
$MM_dupKey .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $MM_dupKey));
// recuperation des valeurs du formulaire
$offre = $_POST['offre'];
// on regarde si les valeurs exitent déjà
$sql = sprintf("SELECT * FROM shop_offres WHERE offre=%s",GetSQLValueString($offre, "text"));
mysql_select_db($database_centphzuone, $centphzuone);
$req=mysql_query($sql, $centphzuone) or die(mysql_error());
// on compte le nombre de résultats
$res = mysql_num_rows($req);
if($res!=0) // Le nom existe déjà, on affiche un message d'erreur
{
$MM_dupKey="requser=";
header ("Location: $MM_dupKey");
exit;
}
else
{
// insertion de l'offre dans la base
$currentPage = $_SERVER["PHP_SELF"];
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
$insertSQL = sprintf("INSERT INTO shop_offres ( client, article, offre, date) VALUES ( %s, %s, %s, %s)",
GetSQLValueString($_POST['client'], "text"),
GetSQLValueString($_POST['article'], "int"),
GetSQLValueString($_POST['offre'], "text"),
GetSQLValueString($_POST['date'], "text"));
mysql_select_db($database_centphzuone, $centphzuone);
$Result1 = mysql_query($insertSQL, $centphzuone) or die(mysql_error());
$insertGoTo = "suppr_panier400.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
} |