Visualizzazione risultati 1 fino 7 di 7

Discussione: Problema con scrittura dati nel DB

  1. #1
    Guest

    Predefinito Problema con scrittura dati nel DB

    Ciao a tutti
    Sono completamente a digiuno di php DB ecc ma cio nonostante mi sono avventurato nel test di un DB per un gioco di ruolo

    ho deciso quindi di installarlo su altervista da autodidatta e sembra funzionicchiare fatto salvo che mi incaglio al primo passo

    nel momento in cui vado a creare un nuovo utente

    http://digichat.altervista.org/php5/...ewregister.php

    finisco di completare tutti i campi e invio ma...
    mi chiede di inserire uno username (cosa che ho ovviamente fatto)

    sbirciando fra i files ho eliminato il controllo sulla presenza username e ho riprovato ma si incaglia al secondo controllo quello sulla lunghezza.

    in pratica sembra che non veda assolutamente quello che inserisco nei vari "fields" della pagina

    qualche consiglietto?

    Grazie a tutti

  2. #2
    L'avatar di mythologia
    mythologia non è connesso Moderatore
    Data registrazione
    05-01-2004
    Messaggi
    2,614

    Predefinito

    Beh, servirebbe di vedere il codice per capire dov'è il problema

  3. #3
    Guest

    Predefinito

    Codice PHP:
    <?php "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?".">" ?>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <title>The Patron Game Engine</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <script language="JavaScript" src="../site_includes/ddmenu.js" type="text/javascript"></script>
    <link rel="stylesheet" type="text/css" href="../style.css">
    </head>
    <body class="general">
    <table width="800" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr>
    <td><table width="100%" border="0" cellspacing="0" cellpadding="0" class="general2">
    <tr>
    <td><table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" class="table1">
    <tr>
    <td colspan="2" align="center"> <img src="../images/title.jpg" alt="Patron Game Engine"></td>
    </tr>
    <tr>
    <td width="140" rowspan="2" valign="top"><form name="form" id="form" method="post" action="../index.php?do=login">
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
    <tr>
    <td><div align="center"><p class="topichead">User Name</p></div></td>
    </tr>
    <tr>
    <td><div align="center">
    <input name="fusername" type="text" id="fusername" size="16" maxlength="16" class="form">
    </div></td>
    </tr>
    <tr>
    <td><div align="center"><p class="topichead">Password</p></div></td>
    </tr>
    <tr>
    <td><div align="center">
    <input type="password" name="fpassword" id="fpassword2" size="16" maxlength="16" class="form">
    </div></td>
    </tr>
    <tr>
    <td><div align="center">
    <input name="log" type="submit" id="log2" value="Login" class="form">
    </div></td>
    </tr>
    <tr>
    <td><hr align="center"></td>
    </tr>
    <tr>
    <td>
    <p>
    <?php
    if (isset($message))
    echo
    "<tr><td colspan='3'>$message </td></tr>";
    ?>
    <tr><td><p align="center" class="topichead"><a href="http://digichat.altervista.org/php5/player_tools/newregister.php">Register</a><br>
    <a href="http://digichat.altervista.org/php5/player_tools/getnewpassword.php">Lost Password</a></p>
    </td>
    </tr>
    </table>
    </form></td>
    <td valign="top"><?php
    require('../site_includes/ddmenu.php');
    ?></td>
    </tr>
    <tr>
    <td width="660" valign="top"><table width="100%" border="0" cellspacing="2" cellpadding="2">
    <tr>
    <td>
    <?php
    require('register.php');
    ?>
    </td>
    </tr>
    </table> </td>
    </tr>
    </table></td>
    </tr>
    </table></td>
    </tr>
    <tr>
    <td align="center">
    <?php
    require('../site_includes/footer.php');
    ?> </td>
    </tr>
    </table>
    <p>&nbsp;</p>
    </body>
    </html>

  4. #4
    Guest

    Predefinito

    Quello che hai postato è una semplice pagina html (con del php dentro) ma che non agisce in nessun modo sul database nè su altre cose.

    PS: l'html che ne deriva non è corretto, ma questo è il male minore per ora.


    Ciao!

  5. #5
    Guest

    Predefinito

    Provo con questo altrimenti dovreste darmi qualche indicazione :(
    Codice PHP:
    <?php include ("../site_includes/gamengdb.php"); ?>
    <html>
    <head><title>New Member Registeration Page</title>
    </head>
    <body>
    <?php
    if ($_POST[submit]=="Register")
    {
    /* Check that username is at 4 characters long, change if you desire more or less, max for field is 32 */
    if (strlen(trim($log_name)) < 4 )
    { echo
    "<center><strong><p class='error'>Username must be at least four characters.</p></strong><p><a href='javascript:history.back()'>Try Again</a></p></center>";
    $_POST=NULL;
    exit();
    }
    /* Check for duplicate name, this includes Player and Character names. */
    $sql="SELECT log_name FROM game_data WHERE log_name='$log_name'";
    $result=mysql_query($sql) or die ("Unable to get member names.<br>'.mysql_error().'<br>");
    $num=mysql_numrows($result);
    if (
    $num>0)
    { echo
    "<center><strong><p class='error'>Name already in use please try another.</p></strong><p><a href='javascript:history.back()'>Try Again</a></p></center>";
    $_POST=NULL;
    exit();
    }
    /* Check for password */
    if ($fpassword =="")
    { echo
    "<center><strong><p class='error'>You must enter a password.</p></strong><p><a href='javascript:history.back()'>Try Again</a></p></center>";
    $_POST=NULL;
    exit();
    }
    /* Check that password is at least 5 characters long, change if you desire more or less, max for field is 32 */
    if (strlen(trim($fpassword)) < 5 )
    { echo
    "<center><strong><p class='error'>Password must be at least five characters.</p></strong><p><a href='javascript:history.back()'>Try Again</a></p></center>";
    $_POST=NULL;
    exit();
    }
    /* Check that password and confirmed password match */
    if ($fpassword != $confirmpw)
    { echo
    "<center><strong><p class='error'>Password and retype password do not match.</p></strong><p><a href='javascript:history.back()'>Try Again</a></p></center>";
    $_POST=NULL;
    exit();
    }
    /* Check for age */
    if ($user_age =="")
    { echo
    "<center><strong><p class='error'>You must enter your age.</p></strong><p><a href='javascript:history.back()'>Try Again</a></p></center>";
    $_POST=NULL;
    exit();
    }
    /* Check for min age, set to 18 years old, if you desire younger change. */
    if ($user_age < "18")
    { echo
    "<center><strong><p class='error'>You must must be at least 18 to join.</p><p><a href='javascript:history.back()'>Try Again</a></p></center>";
    $_POST=NULL;
    exit();
    }
    /* Check for email address */
    if ($email =="")
    { echo
    "<center><strong><p class='error'>You must enter an e-mail address.</p></strong><p><a href='javascript:history.back()'>Try Again</a></p></center>";
    $_POST=NULL;
    exit();
    }
    /* Check for correct email format, correct format is ?????@???.??? or ?????@???.?? */
    if (!ereg('^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$', $email))
    { echo
    "<center><strong><p class='error'>E-mail address format is not valid.</p></strong><p><a href='javascript:history.back()'>Try Again</a></p></center>";
    $_POST=NULL;
    exit();
    }
    /* Check for duplicate email, if you do not care, remove this section */
    $sql="SELECT email FROM game_data WHERE email='$email'";
    $result=mysql_query($sql) or die ("Unable to get member email.<br>'.mysql_error().'<br>");
    $num=mysql_numrows($result);
    if (
    $num>0)
    { echo
    "<center><strong><p class='error'>Email already in use please use another.</p></strong><p><a href='javascript:history.back()'>Try Again</a></p></center>";
    $_POST=NULL;
    exit();
    }
    /* Check for acceptance */
    if ($accept_tos != "Yes")
    { echo
    "<center><strong><p class='error'>You must agree to the terms and conditions of use.</p></strong><p><a href='javascript:history.back()'>Try Again</a></p></center>";
    $_POST=NULL;
    exit();
    }
    else
    $query="INSERT INTO game_data
    (log_name,date_joined,account_type,password,email,show_email,time_zone,alt_contact,user_age,gender,web_site,comments,char_type) VALUE (\"
    $_POST[log_name]\",NOW(),\"$_POST[account_type]\",\"$_POST[fpassword]\",\"$_POST[email]\",\"$_POST[show_email]\",\"$_POST[time_zone]\",\"$_POST[alt_contact]\",\"$_POST[user_age]\",\"$_POST[gender]\",\"$_POST[web_site]\",\"$_POST[comments]\",\"$_POST[char_type]\")";
    $result = mysql_query($query) or die("Couldn't add user.<br>".mysql_error()."<br>");
    echo
    "<br><center><p>Welcome to the game $log_name,<br> records/*
    else
    {
    ?>
    <form action="
    <?=$PHP_SELF?>" method="POST">
    <input name="account_type" type="hidden" value="Player">
    <input name="char_type" type="hidden" value="">
    <table width="525" border="0" align="center">
    <tr>
    <td align="right"><strong><p>User Name</p></strong></td>
    <td><input type="text" name="log_name" id="log_name" size="32" maxlength="32" class="form"></td>
    <td><small><p>(Min 4 Characters)</p></small></td>
    </tr>
    <tr><td align="right"><strong><p>Password</p></strong></td>
    <td><input type="password" name="fpassword" id="fpassword" size="32" maxlength="32" class="form"></td>
    <td><small><p>(Min 5 Characters)</p></small></td>
    </tr>
    <tr>
    <td align="right"><strong><p>Retype Password</p></strong></td>
    <td><input type="password" name="confirmpw" id="confirmpw" size="32" maxlength="32" class="form"></td>
    <td>&nbsp;</td>
    </tr>
    <tr><td align="right"><strong><p>E-Mail</p></strong></td>
    <td><input type="text" name="email" id="email" size="32" maxlength="128" class="form"></td>
    <td><small><p>(Enter in lowercase)</p></small></td>
    </tr>
    <tr>
    <td align="right"><strong><p>Show E-Mail</p></strong></td>
    <td>
    <select name="show_email" id="show_email" class="form">
    <option value="Yes" selected>Yes</option>
    <option value="No">No</option>
    </select></td>
    <td><small><p>(Visible to non-staff?)</p></small></td>
    </tr>
    <tr><td align="right"><strong><p>Age</p></strong></td>
    <td><input type="text" name="user_age" id="user_age" size="1" maxlength="2" class="form"></td>
    <td>&nbsp;</td>
    </tr>
    <tr>
    <td colspan="3"><div align="center"><hr width="75%"></div></td>
    </tr>
    <tr>
    <td align="right"><strong><p>Gender</p></strong></td>
    <td>
    <select name="gender" id="gender" class="form">
    <option value="" selected></option>
    <option value="Male">Male</option>
    <option value="Female">Female</option>
    </select> </td>
    <td>&nbsp;</td>
    </tr>
    <tr>
    <td align="right"><strong><p>Time Zone</p></strong> </td>
    <td><select name="time_zone" id="time_zone" class="form">
    <option value="GMT -12 Hours">GMT -12 Hours</option>
    </select></td>
    <td>&nbsp;</td>
    </tr>
    <tr>
    <td align="right"><strong><p>AIM/MSN/YM</p></strong> </td>
    <td><input type="text" name="alt_contact" id="alt_contact" size="32" maxlength="128" class="form"></td>
    <td>&nbsp;</td>
    </tr>
    <tr>
    <td align="right"><strong><p>Website</p></strong> </td>
    <td><input type="text" name="web_site" id="web_site" size="32" maxlength="128" class="form"></td>
    <td>&nbsp;</td>
    </tr>
    <tr>
    <td align="right"><strong><p>Comments</p></strong></td>
    <td><input type="text" name="comments" id="comments" size="32" maxlength="255" class="form"></td>
    <td>&nbsp;</td>
    </tr>
    <tr>
    <td colspan="3"><div align="center"><hr width="75%"></div></td>
    </tr>

    <tr>
    <td colspan="2"><div align="center"><p>Do you accept the to the <a href="#">terms and conditions of use</a>?</p></div></td>
    <td><select name="accept_tos" id="accept_tos" class="form">
    <option value="Yes">Yes</option>
    <option value="No" selected>No</option>
    </select></td>
    </tr>
    <tr>
    <td colspan="3"><div align="center"><hr width="75%"></div></td>
    </tr>
    <tr><td>&nbsp;</td>
    <td align="center"><input type="submit" name="submit" value="Register" class="form"></td>
    <td align="center">&nbsp;</td>
    </tr>
    </table>
    </form>
    <?php
    }
    ?>
    </body>
    </html>

  6. #6
    Guest

    Predefinito

    Credo che il problema sia qui o meglio la parte interessante sia qui
    Codice PHP:
    }
    else
    $query="INSERT INTO game_data
    (log_name,date_joined,account_type,password,email,show_email,time_zone,alt_contact,user_age,gender,web_site,comments,char_type) VALUE (\"
    $_POST[log_name]\",NOW(),\"$_POST[account_type]\",\"$_POST[fpassword]\",\"$_POST[email]\",\"$_POST[show_email]\",\"$_POST[time_zone]\",\"$_POST[alt_contact]\",\"$_POST[user_age]\",\"$_POST[gender]\",\"$_POST[web_site]\",\"$_POST[comments]\",\"$_POST[char_type]\")";
    $result = mysql_query($query) or die("Couldn't add user.<br>".mysql_error()."<br>");
    echo
    "<br><center><p>Welcome to the game $log_name,<br>An email has been sent with your member name and password for your records.<br>Please save them for referance.<br><br>You may now log in at the left.</p></center>";
    /* Send Email to new member. Be sure to correct all the information or customize it to your liking. If you want to remove it delete this section down to but not including the }, if you with to temporaryly disable the sending place a # infront of $mailsend */
    $emess.= "We appreciate your interest in playing in the World of Darkness";
    $emess.= " at (GameSite).\n";
    $emess = "Your new member account has been setup ";
    $emess.= "with the member name and password of: ";
    $emess.= "\n\t$log_name\n\t$fpassword\n\n";
    $emess.= "If you have any questions or problems,";
    $emess.= " email administrator@gamesite.com";
    $ehead="From: administrator@gamesite.com\r\n";
    $subj = "Your new member account for (GameSite)";
    $mailsend=mail("$email","$subj","$emess","$ehead");
    }
    else
    in pratica credo sia qui che indica il DB sul quale agire inquanto GAME_DATA è una tabella del db...o mi sbaglio

  7. #7
    L'avatar di saitfainder
    saitfainder non è connesso Sëniör Stäff
    Data registrazione
    06-12-2002
    Residenza
    Torino
    Messaggi
    8,715

    Predefinito

    Mancano troppi pezzi per riuscire a capire di cosa si tratta e sarebbe utile indicare anche il nome dei file che hai allegato. Però così, a occhio, non mi sembra che possa essere legato al DB, visto che altrimenti ti visualizzerebbe un qualche messaggio di errore.

    Intanto prova a controllare se e cosa è stato scritto nel DB. Cmq prima di cominciare a mettere mani su PHP+SQL sarebbe meglio studiarsi almeno i rudimenti.


    «È una mia peculiarità distorcere la verità e inventarne di nuove.»
    «I tuoi orientamenti hanno su di me un effetto prossimo allo zero.»


Regole di scrittura

  • Non puoi creare nuove discussioni
  • Non puoi rispondere ai messaggi
  • Non puoi inserire allegati.
  • Non puoi modificare i tuoi messaggi
  •