<?php require_once('Connections/camere.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 = $_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 stato_pren (numero_camere, cognome, nome, indirizzo, telefono, fax, email, data_prenotazione, data_arrivo, data_partenza, stato) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['numero_camere'], "text"),
GetSQLValueString($_POST['cognome'], "text"),
GetSQLValueString($_POST['nome'], "text"),
GetSQLValueString($_POST['indirizzo'], "text"),
GetSQLValueString($_POST['telefono'], "text"),
GetSQLValueString($_POST['fax'], "text"),
GetSQLValueString($_POST['email'], "text"),
GetSQLValueString($_POST['data_prenotazione'], "date"),
GetSQLValueString($_POST['data_arrivo'], "date"),
GetSQLValueString($_POST['data_partenza'], "date"),
GetSQLValueString($_POST['stato'], "text"));
mysql_select_db($database_camere, $camere);
$Result1 = mysql_query($insertSQL, $camere) or die(mysql_error());
$insertGoTo = "cercastatopren.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
mysql_select_db($database_camere, $camere);
$query_Recordset1 = "SELECT * FROM stato_pren WHERE stato_pren.data_arrivo<='$data_partenza' AND stato_pren.data_partenza>='$data_arrivo'";
$Recordset1 = mysql_query($query_Recordset1, $camere) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?>
Vorrei aggiungere un cotrollo di inserimento,se la camera 1 con la data_arrivo e la data_partenza gia esiste mi deve dare camera gia prenotata,ma non so dove inserire questo controllo.
grazie
ciao