Innanzitutto, per una migliore comprensione metti il codice tra [PHP*] [/PHP*]. Cosi'
Codice 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"] == "registrazione")) {
$insertSQL = sprintf("INSERT INTO utenti (username, password, nome, email, sesso, newsletter, attivita, messaggio) VALUES (%s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['textfield'], "text"),
GetSQLValueString($_POST['textfield2'], "text"),
GetSQLValueString($_POST['textfield'], "text"),
GetSQLValueString($_POST['textfield'], "text"),
GetSQLValueString($_POST['textfield'], "int"),
GetSQLValueString($_POST['textfield'], "int"),
GetSQLValueString($_POST['textfield'], "int"),
GetSQLValueString($_POST['textfield'], "text"));
mysql_select_db($database_utenti, $utenti);
$Result1 = mysql_query($insertSQL, $utenti) or die(mysql_error());
$insertGoTo = "server.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
Inoltre, posto che la struttura della tabella utenti e'
username, password, nome, email, sesso, newsletter, attivita, messaggio
inviaci la parte di codice sql che non ti funziona.
Facci sapere.