ho creato una registrazione per utenti al mio sito. queste le pagine:
iscrizione_sito.php
elabora_guest.phpcodice:<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Iscriviti al mio sito!</title> </head> <body background="http://crash.inc.md/img/background3.gif" text="white" link="white" vlink="white" bgproperties="fixed"> Iscriviti al mio sito, cosi potrai accedere alle aree riservate. La procedura è semplice: compila il modulo sottostante. Ti ricordo che i campi segnati con l'asterisco (*) sono obbligatori. <table> <form name="modulo" action="elabora_guest.php" method="post"> <tr><td>Scegli un username:*</td><td><input type="text" name="ob_username" size="12" maxlength="12"></td></tr> <tr><td>Scegli una password:*</td><td><input type="password" name="ob_password" size="12" maxlength="12"></td></tr> <tr><td>Ripeti la password:*</td><td><input type="password" name="ob_ripetipassword" size="12" maxlenght="12"></td></tr> <tr><td colspan="2" align="center"><input type="submit" value="iscriviti!" name="invio"></td></tr> </form> </table> </body> </html>
codice:<?php $host = "localhost"; $username = "crash_crash"; $password = "password database"; $database = "crash_crash"; $db=mysql_connect($host, $username, $password) or die("Errore durante la connessione al database"); $selezione_db=mysql_select_db($database, $db) or die("Errore durante la selezione del database"); ?> <html> <head> <title>iscrizione in corso...</title> </head> <body background="http://crash.inc.md/img/background3.gif" text="white" link="white" vlink="white" bgproperties="fixed"> <?php //CONTROLLO CHE TUTTI I CAMPI SIANO STATI COMPILATI $flag_controllo=0; while(list($chiave, $valore)=each($_POST)){ if(substr($chiave,0,2)=="ob_"){ if($valore==""){ echo "non hai compilato il campo obbligatorio $chiave, l'iscrizione non può continuare."; $flag_controllo=1; break; } } }; reset($_POST); if($flag_controllo==0){ //CONTROLLO CHE NON ESSTE GIA UN UTENTE REGISTRATO CON LO STESSO USER SCELTO $controlloutente="select * from utenti where utente=\"$_POST[ob_username]\""; $querycontrollo=mysql_query($controlloutente,$connessione); $contorecord=mysql_num_rows($querycontrollo); if($contorecord>0){ echo "esiste già un utente registrato con il nome $_POST[ob_username]"; } else { //CONTROLLO CHE I CAMPI PASSWORD E RIPETI PASSWORD SIANO UGUALI if($_POST[ob_password]==$_POST[ob_ripetipassword]){ //SONO UGUALI, PROCEDO ALL'INSERIMENTO $utente=addslashes(htmlspecialchars(trim($_POST[ob_username]))); $password=addslashes(htmlspecialchars(trim($_POST[ob_password]))); $inserimentoutente="insert into utenti (ob_username, ob_password) values(\"$_POST[ob_username]\",\"$_POST[ob_password]\")"; if(mysql_query($inserimentoutente)==TRUE){ echo "<h3><p align=\"center\">[b]Registrazione effettuata con successo!!</p></h3> "; echo "<h5>I dati con i quali vi siete registrato sono i seguenti: "; echo "username: $_POST[ob_username] "; echo "password: $_POST[ob_password] "; } } else { echo "il valore inserito nel campo Password e in quello ripeti password non coincidono"; } } } ?> </body> </html>
la pagina è questa: http://crash.inc.md/iscrizione_sito/iscrizione_sito.php
una volta spediti i dati ad elabora_guest.php mi esce il mex:
Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /usr/home/users/crash/www/crash.inc.md/iscrizione_sito/elabora_guest.php on line 33
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /usr/home/users/crash/www/crash.inc.md/iscrizione_sito/elabora_guest.php on line 34
Registrazione effettuata con successo!!
I dati con i quali vi siete registrato sono i seguenti:
username: xxx
password: xxx
i dati li inserisce nel database, ma ci sono quei errori!
qualcuno mi può aiutare? ho provato di tutto ma non ci riesco a risolvere il problema.
grazie
ciao

Rispondi quotando