Questo è lo script in questione,
ho provato ma non funzione, mi restituisce sempre l'errore
che il campo ip non può contenere un valore null.
<?php require_once('Connections/annunci.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 annunci (ip, oggetto, descrizione, telefono) VALUES (%s, %s, %s, %s)",
GetSQLValueString($HTTP_POST_VARS['ip'], "text"),
GetSQLValueString($HTTP_POST_VARS['oggetto'], "text"),
GetSQLValueString($HTTP_POST_VARS['descrizione'], "text"),
GetSQLValueString($HTTP_POST_VARS['telefono'], "text"));
mysql_select_db($database_annunci, $annunci);
$Result1 = mysql_query($insertSQL, $annunci) or die(mysql_error());
$insertGoTo = "conferma.php";
if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $HTTP_SERVER_VARS['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
?>
<?php echo "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?".">"; ?>
<html>
<head>
<title>Untitled Document</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">Oggetto:</td>
<td><input type="text" name="oggetto" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Descrizione:</td>
<td><input type="text" name="descrizione" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Telefono:</td>
<td><input type="text" name="telefono" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">&nbsp;</td>
<td><input type="submit" value="Insert Record"></td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="form1">
<input name="ip" type="hidden" id= <? echo $REMOTE_ADDR; ?> />
</form>
</body>
</html>