problema con registrazione utenti

danilob

Utente Attivo
3 Feb 2007
124
0
0
buongiorno a tutti,
sono nuovo di PhP e seguendo una guida ho provato a inserire nel mio sito un processo di registrazione utente e accesso a un'area riservata.
Il problema nasce quando l'utente cerca di registrarsi. Nella pagina di registrazione ho inserito il form ma una volta compilato alla pressione del pulsante invia al posto di comparirmi la pagina di conferma che mostra i campi compilati, mi compare nuovamente il form con i campi vuoti. Riporto una parte del codice sperando che qualcuno mi possa essere un po' d'aiuto o almeno vi chiedo gentilmente si potete consigliare uno script o qualcosa del genere che si occupi del processo di login e inserimento utenti. Dimenticavo una cosa lo stesso problema si presenta anche quando cerco di effettuare il oggi, non succede nulla, anche se ho registrato l'utente nel database manualmente e usando mysql. Penso si tratti di qualcosa mal settato all'interno della configurazione del mio PC ma credetemi dopo mesi e mesi di letture nei vari form ho pensato di scrivere perché stò perdendo la speranza.
riporto di fare il register.php:

<?php
//register.php
include_once "./common_db.inc";

function in_use($userid) {
global $user_tablename;

$query = "SELECT userid FROM $user_tablename WHERE userid = '$userid'";
$result = mysql_query($query);
if(!mysql_num_rows($result)) return 0;
else return 1;
}

function register_form() {
global $userposition;
global $PHP_SELF;

$link_id = db_connect();
mysql_select_db("sample_db");
$position_array = enum_options('userposition', $link_id);
mysql_close($link_id);

?>


<CENTER><H3>Create your account!</H3></CENTER>
<FORM METHOD="post" ACTION="<?php echo $PHP_SELF ?>">
<INPUT TYPE="HIDDEN" NAME="action">
<DIV ALIGN="CENTER"><CENTER><TABLE BORDER="1" WIDTH="90%">
<TR>
<TH WIDTH="30%" NOWRAP>Desired ID</TH>
<TD WIDTH="70%"><INPUT TYPE="TEXT" NAME="userid"
SIZE="8" MAXLENGTH="8"></TD>
</TR>
<TR>
<TH WIDTH="30%" NOWRAP>Desired Password</TH>
<TD WIDTH="70%"><INPUT TYPE="PASSWORD"
NAME="userpassword" SIZE="15"></TD>
</TR>
<TR>
<TH WIDTH="30%" NOWRAP>Retype Password</TH>
<TD WIDTH="70%"><INPUT TYPE="PASSWORD"
NAME="userpassword2" SIZE="15"></TD>
</TR>
<TR>
<TH WIDTH="30%" NOWRAP>Full Name</TH>
<TD WIDTH="70%"><INPUT TYPE="TEXT" NAME="username" SIZE="20"></TD>
</TR>
<TR>
<TH WIDTH="30%" NOWRAP>Position</TH>
<TD WIDTH="70%"><SELECT NAME="userposition" SIZE="1">
<?php


for($i=0; $i < count($position_array); $i++) {
if(!isset($userposition) && $i == 0) {
echo "<OPTION SELECTED VALUE=\"". $position_array[$i] .
"\">" . $position_array[$i] . "</OPTION>\n";
}
else if($userposition == $cposition_array[$i]) {
echo "<OPTION SELECTED VALUE=\"". $position_array[$i] . "\">" .
$position_array[$i] . "</OPTION>\n";
}
else {
echo "<OPTION VALUE=\"". $position_array[$i] . "\">" .
$position_array[$i] . "</OPTION>\n";
}
}
?>


</SELECT></TD>
</TR>
<TR>
<TH WIDTH="30%" NOWRAP>Email</TH>
<TD WIDTH="70%"><INPUT TYPE="TEXT" NAME="useremail" SIZE="20" >
</TD>
</TR>
<TR>
<TH WIDTH="30%" NOWRAP>Profile</TH>
<TD WIDTH="70%"><TEXTAREA ROWS="5" COLS="40"
NAME="userprofile"></TEXTAREA></TD>
</TR>
<TR>
<TH WIDTH="30%" COLSPAN="2" NOWRAP>
<INPUT TYPE="SUBMIT" VALUE="Submit">
<INPUT TYPE="RESET" VALUE="Reset"></TH>
</TR>
</TABLE>
</CENTER></DIV>
</FORM>
<?php
}

function create_account() {
$userid = $_POST['userid'];
$username = $_POST['username'];
$userpassword = $_POST['userpassword'];
$userpassword2 = $_POST['userpassword2'];
$userposition = $_POST['userposition'];
$useremail = $_POST['useremail'];
$userprofile = $_POST['userprofile'];

global $default_dbname, $user_tablename;


if(empty($userid)) error_message("Enter your desired ID!");
if(empty($userpassword)) error_message("Enter your desired password!");
if(strlen($userpassword) < 4 ) error_message("Password too short!");
if(empty($userpassword2))
error_message("Retype your password for verification!");
if(empty($username)) error_message("Enter your full name!");
if(empty($useremail)) error_message("Enter your email address!");
if(empty($userprofile)) $userprofile = "No Comment.";

if($userpassword != $userpassword2)
error_message("Your desired password and retyped password mismatch!");



$link_id = db_connect($default_dbname);

if(in_use($userid))
error_message("$userid is in use. Please choose a different ID.");


$query = "INSERT INTO user VALUES(NULL, '$userid', password('$userpassword'),
'$username', '$userposition', '$useremail', '$userprofile')";
$result = mysql_query($query);
if(!$result) error_message(sql_error());


$usernumber = mysql_insert_id($link_id);
html_header();
?>


<CENTER><H3>
<?php echo $username ?>, thank you for registering with us!
</H3></CENTER>

<DIV ALIGN="CENTER"><CENTER><TABLE BORDER="1" WIDTH="90%">
<TR>
<TH WIDTH="30%" NOWRAP>User Number</TH>
<TD WIDTH="70%"><?php echo $usernumber ?></TD>
</TR>
<TR>
<TH WIDTH="30%" NOWRAP>Desired ID</TH>
<TD WIDTH="70%"><?php echo $userid ?></TD>
</TR>
<TR>
<TH WIDTH="30%" NOWRAP>Desired Password</TH>
<TD WIDTH="70%"><?php echo $userpassword ?></TD>
</TR>
<TR>
<TH WIDTH="30%" NOWRAP>Full Name</TH>
<TD WIDTH="70%"><?php echo $username ?></TD>
</TR>
<TR>
<TH WIDTH="30%" NOWRAP>Position</TH>
<TD WIDTH="70%"><?php echo $userposition ?></TD>
</TR>
<TR>
<TH WIDTH="30%" NOWRAP>Email</TH>
<TD WIDTH="70%"><?php echo $useremail ?></TD>
</TR>
<TR>
<TH WIDTH="30%" NOWRAP>Profile</TH>
<TD WIDTH="70%"><?php echo htmlspecialchars($userprofile) ?></TD>
</TR>
</TABLE>
</CENTER></DIV>
<?php
html_footer();
}

if (empty($_POST)) $_POST['action'] = "";

switch($_POST['action']) {
case "register":
create_account();
break;
default:
html_header();
register_form();
html_footer();
break;
}
?>
 

Eliox

Utente Attivo
25 Feb 2005
4.390
3
0
stampati tutto quello che viene inviato tramite POST e vedi se almeno qualche parametro viene passato dal form.
 

Eliox

Utente Attivo
25 Feb 2005
4.390
3
0
Prova a commentare la riga:
PHP:
if(!$result) error_message(sql_error());

e correggi questa:
PHP:
$result = mysql_query($query);

così

PHP:
$result = mysql_query($query) or die (mysql_error());

e vedi se ti viene notificato qualche errore.
 

danilob

Utente Attivo
3 Feb 2007
124
0
0
niente quando premo sbmit mi cancella tutto e mi ricompare il form vuoto. Sai non riesco a trovare nessuno che mi aiuti ti ringrazio moltissimo. Sono mesi che provo e riprovo ma nulla... Grazie
 

Eliox

Utente Attivo
25 Feb 2005
4.390
3
0
Lo script include troppe funzioni esterne, così è un pò difficile trovare l'errore.
 

danilob

Utente Attivo
3 Feb 2007
124
0
0
ti posso inviare i file se hai voglia. Fammi il piacere... Non sò più dove sbatter la testa.. Ho già letto di tutto e credimi mi spiace romper le scatole ma vorrei tantissimo trovare una soluzione...
 
Discussioni simili
Autore Titolo Forum Risposte Data
marino51 problema con registrazione al forum Supporto Mr.Webmaster 4
D Form Registrazione con conferma via email - problema PHP 10
P Problema con file di registrazione in php, non funziona e dà continui errori PHP 0
M Problema con modulo registrazione e inserimento dati in database PHP 8
T Problema con script di registrazione utenti su IE PHP 4
E problema con nomi registrazione PHP 8
neo996sps Problema con tutorial registrazione utenti PHP 1
W Problema Registrazione Punteggio con giochi PHP 0
O problema con dvr dahua xvr5116 IP Cam e Videosorveglianza 0
G Problema con Xampp Web Server 1
andrea barletta Problema con miniature comandi Photoshop 0
I problema con alice Posta Elettronica 0
N Problema con position absolute e overflow HTML e CSS 4
L Problema con inner join PHP 11
K [php] Problema con inner join PHP 4
K [PHP] Problema con variabili concatenate. PHP 1
O problema con query PHP 4
I problema con 2 account Posta Elettronica 1
L problema collegamento file css con html HTML e CSS 1
E Problema accesso a file con app sviluppata con MIT APP INVENTOR 2 Sviluppo app per Android 0
M Problema con Try Catch PHP 0
Sergio Unia Problema con gli eventi del mouse su una data table: Javascript 2
T PROBLEMA CON SESSIONI PHP 3
T ALTRO PROBLEMA CON ARRAY PHP PHP 1
R problema con else PHP 0
T PROBLEMA CON ARRAY PHP 8
L problema con query select PHP 2
R Problema query con ricerca id numerico PHP 2
F Problema con risposta PHP 0
S problema con recupero dati tabella mysql PHP 2
Z Problema con il mio tp-l i nk Reti LAN e Wireless 1
L Problema RAM con Tomcat 8 Apache 0
napuleone problema con sort e asort PHP 4
Z Problema con INT MySQL PHP 1
Z Problema database MySQL con XAMPP PHP 0
M Problema con controllo form in real time jQuery 6
Z Problema di sincronizzazione PAYPAL con PHP PHP 1
G Problema con Get page PHP 4
P Problema con require once PHP 6
P Problema con i package Java 1
A Problema login con Safari PHP 14
F INDESIGN: problema esportazione esecutivo per la stampa con foto B/N Webdesign e Grafica 0
S problema con css bootstrap3 HTML e CSS 4
M .load() problema con caricamenti dinamici di js Javascript 0
G Problema con eccessiva nitidezza apertura Camera Raw Photoshop 0
G Problema ------- con Query PHP 1
G Problema con Query PHP 1
T problema con select dinamica con jquery Javascript 0
S Problema con spazi bianchi HTML e CSS 5
A PROBLEMA: insert mysqli con dati Tagsinput Presentati al Forum 0

Discussioni simili