Ciao a tutti, potreste controllare cosa non va in questo codice? ne mysql ne php mi danno errori però i dati che chiedo di inserire non vengono inseriti e non capisco il perchè![]()
Allora, dove ci sono i puntini è parte di codice che reputo poco importante per la domanda che vi porgo, spero sia vero, altrimenti fatemi sapere e vi invio la pagina intera. Cmq il problema è che nel database non viene registrata la variabile $ANIMALE, tutte le altre invece vengono registrate normalmente.codice:$RAZZA=$_POST['RAZZA']; . . . //Assegnazione Animale per i Lyarcon if ($RAZZA == 'Lyarcon'){ $ANIMALE_NUM = mt_rand(1,6); if ($ANIMALE_NUM == 1){ $ANIMALE == 'Falco'; } elseif ($ANIMALE_NUM == 2){ $ANIMALE == 'Scimmia'; } elseif ($ANIMALE_NUM == 3){ $ANIMALE == 'Lupo'; } elseif ($ANIMALE_NUM == 4){ $ANIMALE == 'Orso'; } elseif ($ANIMALE_NUM == 5){ $ANIMALE == 'Ermellino'; } elseif ($ANIMALE_NUM == 6){ $ANIMALE == 'Riccio'; } } . . . . $sql = "INSERT INTO USERS (CORPORAZIONE_TIPO,STATO_TIPO,FUNZIONE_T IPO,USERNAME,PASS,MAILREG,URLAVATAR,SESS O,RAZZA,URLSESSO,ESPERIENZA,SALUTE,BROWS ER,ANIMALE,DATAREG,REGIP) VALUES ('$CORPORAZIONE_TIPO','$STATO_TIPO','$FU NZIONE_TIPO','$USERNAME','$PASS','$MAILR EG','$URLAVATAR','$SESSO','$RAZZA','$URL SESSO','0','Sano','$_SERVER[HTTP_USER_AG ENT]','$ANIMALE','$DATAREG','$_SERVER[RE MOTE_ADDR]')"; $query = @mysql_query ($sql, $connessione) or die(mysql_error()); . . .
PS: lasciate stare il fatto che sia tutto maiuscolo e altre cose inconsuete, è che sto modificando un gdr opensource, il resto funziona anke se così.
Codice intero non avendo la possibiltà di hostarlo:
codice:<? / *####################################### ########## Citt�virtuale GPL # # Non rimuovere questo commento, grazie. # # Programmatore: (Traimo) Vladimir Inconis # E-mail: traimo at weaponmaster dot org # E-mail: traimo at laforzaoscura dot com # # Programmatore: (Prospero) Luca # E-mail: prosperocolonna_lot at hotmail dot com # # http://www.weaponmaster.org # http://www.laforzaoscura.com # http://www.steamcity.laforzaoscura.com # */ ######################################## ######### ?> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>CittÃ_ virtuale GPL</title> <link rel="stylesheet" href="stile.css" type="text/css"> </head> <body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0"> <?PHP include "config.inc.php"; $PRIMA=$_POST['PRIMA']; $USERNAME=$_POST['USERNAME']; $MAILREG=$_POST['MAILREG']; $SESSO=$_POST['SESSO']; $RAZZA=$_POST['RAZZA']; if ($PRIMA=='TRUE'){ $USERNAME=''; $MAILREG=''; } else if ($PRIMA=='FALSE'){ //LANCIO LA QUERY PER VERIFICARE L'ESISTENZA DELL'UTENTE $sqlver = "SELECT * FROM USERS WHERE USERNAME = '$USERNAME'"; $queryver = @mysql_query ($sqlver, $connessione) or die(mysql_error()); $num_user = mysql_num_rows($queryver); //SE NON ESISTE PROCEDO CON LA VERIFICA DEI DATI E LA CREAZIONE if ($num_user == "0") { echo "<form name='formOK' method='post' action='login.php'>"; echo "</form>"; echo "<script language='Javascript'>"; if (eregi("^[a-z]",$USERNAME)) { if (eregi("^[a-z0-9][_\.a-z0-9-]+@([a-z0-9][0-9a-z-]+\.)+([a-z]{2,4})",$MAILREG)){ //Inserimento dati in DB /*GESTIONE SIMBOLO SESSO*/ if ($SESSO=='Maschio') $URLSESSO='http://localhost/opensource/grafica/mas.gif'; if ($SESSO=='Femmina') $URLSESSO='http://localhost/opensource/grafica/fem.gif'; //Assegnazione Animale per i Lyarcon if ($RAZZA == 'Lyarcon'){ $ANIMALE_NUM = mt_rand(1,5); if ($ANIMALE_NUM == 1){ $ANIMALE == Falco; } elseif ($ANIMALE_NUM == 2){ $ANIMALE == Riccio; } elseif ($ANIMALE_NUM == 3){ $ANIMALE == Volpe; } elseif ($ANIMALE_NUM == 4){ $ANIMALE == Tigre; } elseif ($ANIMALE_NUM == 5){ $ANIMALE == Ermellino; } } /*GESTIONE VARIABILI INIZIALI*/ $URLAVATAR='http://localhost/opensource/grafica/init.gif'; $CORPORAZIONE_TIPO='1'; $STATO_TIPO='1'; $FUNZIONE_TIPO='5'; /*GESTIONE E CREAZIONE PASSWORD*/ function randomPassword () { $length ="8"; $possible = '23456789' . 'abcdefghijkmnpqrstuvwxyz' . 'ABCDEFGHJKLMNPQRSTUVWXYZ'; $str =""; while (strlen($str) < $length) { $str.=substr($possible, (rand() % strlen($possible)),1); } return($str); } $PASS=randomPassword(); /*GESTIONE DATA DI REGISTRAZIONE*/ // setto data e ora in base alla linga locale setlocale (LC_TIME,"it_IT"); // metto data e ora in un array $DATA1 = time(); $date_time_array = getdate($DATA1); $hours = $date_time_array['hours']; $minutes = $date_time_array['minutes']; $seconds = $date_time_array['seconds']; $month = $date_time_array['mon']; $day = $date_time_array['mday']; $year = $date_time_array['year']; $DATA1 = mktime($hours,$minutes,$seconds,$month,$ day,$year); //echo strftime('%H : %M - %A %d %B %Y',$DATA_PROBLEMA); //fine formattazione data $DATAREG = strftime('%H : %M - %d/%m/%y',$DATA1); $USERNAME = str_replace("'", "'", $USERNAME); $sql = "INSERT INTO USERS (CORPORAZIONE_TIPO,STATO_TIPO,FUNZIONE_T IPO,USERNAME,PASS,MAILREG,URLAVATAR,SESS O,RAZZA,URLSESSO,ESPERIENZA,SALUTE,BROWS ER,ANIMALE,DATAREG,REGIP) VALUES ('$CORPORAZIONE_TIPO','$STATO_TIPO','$FU NZIONE_TIPO','$USERNAME','$PASS','$MAILR EG','$URLAVATAR','$SESSO','$RAZZA','$URL SESSO','0','Sano','$_SERVER[HTTP_USER_AG ENT]','$ANIMALE','$DATAREG','$_SERVER[RE MOTE_ADDR]')"; $query = @mysql_query ($sql, $connessione) or die(mysql_error()); /*INVIO MAIL CON I DATI DI REGISTRAZIONE*/ $sender_name = "STAFF - Phyrosia"; $sender_email = "phyrosiastaff@hotmail.it"; $dati_accesso = "Dati di accesso di Phyrosia"; $msg = "Da:\t$sender_name\n"; $msg .= "\n"; $msg .= "E-mail:\t$sender_email\n"; $msg .= "\n"; $msg .= "Oggetto:\t$dati_accesso\n"; $msg .= "\n"; $msg .= "\n"; $msg .= "Username:\t$USERNAME\n"; $msg .= "\n"; $msg .= "Password:\t$PASS\n\n"; $msg .= "\n"; $msg .= "Ti ricodiamo la pagina di accesso a Phyrosia http://localhost/opensource\n"; $msg .= "\n"; $mailheaders = "Form inviato dal servizio registrazione utenti di Citt�virtuale GPL\n"; $mailheaders .= "Rispondi a: $sender_email\n\n"; mail($MAILREG, "Form inviato dal servizio registrazione utenti di Citt�virtuale GPL", $msg, $mailheaders); echo "document.formOK.submit();"; echo "alert ('Operazione eseguita correttamente.')"; }else{ echo "alert ('E-mail non valida.')";} }else{ echo "alert ('Nickname non valido.')";} echo "</script>"; } else if ($num_user == "1"){ echo "<form name='formESISTE' method='post' action='registra_utente.php'>"; echo "</form>"; echo "<script language='Javascript'>"; echo "alert ('Nickname gi�presente del database! Provare con un altro nickname.');"; echo "document.formESISTE.submit();"; echo "</script>"; } } //Avviso l'admin che si è registrato un nuovo utente $TO_POSTA= "admin"; $FROM_POSTA= "Sistema"; $OBJ_POSTA= "Nuovo utente registrato"; $MSG_POSTA= "Si èregistrato un nuovo utente, il suo nick è '$USERNAME'"; $MSG_POSTA = str_replace("<", "<", $MSG_POSTA); $MSG_POSTA = str_replace(">", ">", $MSG_POSTA); $MSG_POSTA = str_replace("'", "'", $MSG_POSTA); $MSG_POSTA = nl2br($MSG_POSTA); //$DATA_POSTA = date ("d/m/Y H:i:s"); //formattazione data // setto data e ora in base alla lingua locale setlocale (LC_TIME,"it_IT"); // metto data e ora in un array $DATAORIG = time(); $date_time_array = getdate($DATAORIG); $hours = $date_time_array['hours']; $minutes = $date_time_array['minutes']; $seconds = $date_time_array['seconds']; $month = $date_time_array['mon']; $day = $date_time_array['mday']; $year = $date_time_array['year']; // aggiungo 7 ore all'orario del server per avere l'ora corretta in Iralia $DATAORIG = mktime($hours + 7,$minutes,$seconds); //fine formattazione data $DATA_POSTA = strftime('%H : %M - %A %d %B %Y',$DATAORIG); $sql = "INSERT INTO POSTA (FROM_POSTA,TO_POSTA,OBJ_POSTA,MSG_POSTA ,DATA_POSTA,NEW_POSTA) VALUES ('$FROM_POSTA','$TO_POSTA','$OBJ_POSTA', '$MSG_POSTA','$DATA_POSTA','1')"; $query = @mysql_query ($sql, $connessione) or die(mysql_error()); @mysql_close ($connessione); ?> <table width="100%" border="0" cellspacing="0" cellpadding="5" align="center"> <tr> <td height="50" align="center" class="RedTIT">SPAZIO RISERVATO AL BANNER</td> </tr> <tr> <td height="50" align="center" class="RedTIT">.: Nuovo giocatore :.</td> </tr> <form name="form1" method="post" action="registra_utente.php"> <tr> <td height="50" align="center"><table width="550" border="0" cellspacing="0" cellpadding="1" bgcolor="000000"> <tr> <td><table border="0" width="570" cellspacing="0" bordercolorlight="#01273F" cellpadding="5" bgcolor="#ffffff"> <tr> <td width="275" height="20" class="RedB">Nome del PG (nickname):</td> <td width="275" height="20"><input name="USERNAME" type="text" class="textfieldBASE" id="USERNAME" value="<?=$USERNAME?>" size="20" maxlength="20"> </td> </tr> <tr> <td height="20" class="RedB">Sesso:</td> <td height="20"> <select name="SESSO" class="textfieldBASE" id="SESSO"> <option value="Maschio" selected>Maschio</option> <option value="Femmina">Femmina</option> </select></td> <tr> <td height="20" class="RedB">Razza: </td> <td> <select name="RAZZA" class="textfieldBASE" id="RAZZA"> <option value="Umano" selected>Umano</option> <option value="Elfo">Elfo</option> <option value="MezzElfo">Mezz'Elfo</option> <option value="Fata">Fata</option> <option value="MezzoDrow">Mezzo Drow</option> <option value="Lyarcon">Lyarcon</option> </select> </td> </tr> </tr> <tr> <td height="20" class="RedB">E-mail:</td> <td height="20"><input name="MAILREG" type="text" class="textfieldBASE" id="MAILREG" value="<?=$MAILREG?>" size="20" maxlength="255"> </td> </tr> <tr> <td height="20" colspan="2" align="center" class="RedB"> <input name="PRIMA" type="hidden" id="PRIMA" value="FALSE"> <input type="submit" value="Registra" class="textfieldBASE" name="submit"></td> </tr> </table></td> </tr> </table></td> </tr> </form> <tr> <td height="50" align="center" valign="middle">Torna alla pagina di login </td> </tr> </table> </body> </html>

Rispondi quotando