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
| $MM_fl="MM_insert";
if (isset($_POST[$MM_fl])) {
$row_Recordset1000['id']=$_GET['id'];
$MM_dupKey='panier400.php?id='.$row_Recordset1000['id'];
// recuperation des valeurs du formulaire
$offre = $_POST['offre'];
$paramart_Panier = $_GET['id'];
// on regarde si les valeurs exitent déjà
$sql = sprintf("SELECT * FROM shop_offres WHERE offre=%s and article=%s",GetSQLValueString($offre, "text"), GetSQLValueString($paramart_Panier, "int"));
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_qs = "?";
if (substr_count($MM_dupKey,"?") >=1) $MM_qs = "&";
$MM_dupKey = $MM_dupKey . $MM_qs ."requser=".$offre;
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, top , up , arch , suppr , date_offre , env , recu ) VALUES ( %s,%s,%s,%s,%s,%s,%s, %s, %s, %s)",
GetSQLValueString($_POST['client'], "text"),
GetSQLValueString($_POST['article'], "int"),
GetSQLValueString($_POST['offre'], "text"),
GetSQLValueString($_POST['top'], "int"),
GetSQLValueString($_POST['up'], "int"),
GetSQLValueString($_POST['arch'], "int"),
GetSQLValueString($_POST['suppr'], "int"),
GetSQLValueString($_POST['date_offre'], "text"),
GetSQLValueString($_POST['env'], "int"),
GetSQLValueString($_POST['recu'], "int"));
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));
}
} |