Ciao ragazzi io avevo fatto questo codice per impostare il controllo su una pagina successiva alla registrazione dove se i campi nome cognome e codfisc erano vuoti il codice non partiva e dava un'errore, e fin qui tutto bene. poi ho fatto una richiesta al database con dreamweaver per estrarre tutti i campi nick e fare un controllo cosìcchè se il campo esistesse già farei mostrare un'altro messaggio d'errore.
Mi aiutate a costruire un codice che compari il $_POST['nick'] ai risultati estratti dalla query e se ne trova anche solo uno uguale da un messaggio d'errore?
vi posto la query d'estrazione fatta da DW e il mio codice:
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($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;
}
}
mysql_select_db($database_connections, $connections);
$query_Recordset1 = "SELECT nick FROM utenti";
$Recordset1 = mysql_query($query_Recordset1, $connections) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?>
Questo invece è il mio codice (la parte "nuova" in grassetto)
if($_POST['nome']=="" || $_POST['cognome']=="" || $_POST['codfisc']=="" ){
?>
<h3>Siamo spiacenti, Si è verificato un problema</h3>
<?php
if($_POST['nome']!= )
} else {
}
}else{
.....