[HELP]Registration page refuses to insert INFO.

Results 1 to 8 of 8
  1. #1
    Account Upgraded | Title Enabled! magicswe is offline
    MemberRank
    May 2005 Join Date
    Sweden, GothenburgLocation
    1,247Posts

    [HELP]Registration page refuses to insert INFO.

    Okay, so i decided to make a own little nice CMS wiz basic shit. Downloaded a webpack since i couldn't be arsed to write all from scratch. Now this registration script i have it refuses to insert info into the database (no errors) However it does tell me that the account is created, and it does tell me that an account already exist if i choose an account name that DOES really exist so IS connected somehow but just refused to insert new account info.

    Infos:
    Table structure:
    login - password - accessLevel - blah blah blah blah

    PHP CODE: The whole .php page.
    PHP Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <script type="text/JavaScript">

    (NVM THIS THINGY LINK INCLUDE HERE)
    include("XXXXXXXX/XXXXXXXX/XXXXXXXX/config_.php");

    function isAlphaNumeric(value)
    {
      if (value.match(/^[a-zA-Z0-9]+$/))
        return true;
      else
        return false;
    }
    function checkform(f)
    {
      if (f.account.value=="")
      {
        alert("Error: You forgot to type in your desired Login name.");
        return false;
      }
      if (!isAlphaNumeric(f.account.value))
      {
        alert("Error code: Illegal characters detected in your Login name!");
        return false;
      }
      if (f.password.value=="")
      {
        alert("Error: You forgot to type in your desired password.");
        return false;
      }
      if (!isAlphaNumeric(f.password.value))
      {
        alert("Error code: Illegal characters detected in your password!");
        return false;
      }
      if (f.password2.value=="")
      {
        alert("Error code: 5");
        return false;
      }
      if (f.password.value!=f.password2.value)
      {
        alert("Error: Passwords doesn't match.");
        return false; 
      }
      return true;
    }
    </script>
    </head>

    <form method="post" action="" onsubmit="return checkform(this)">
      <div align="center">
        <table width="100%" class="reg">
          <tr>
            <td width="19%">&nbsp;</td>
            <td width="31%"><strong>Login</strong></td>
        <td width="50%">
          <input type="text" name="account" id="user" maxlength="15"/></td>
       </tr>
          <tr>
            <td>&nbsp;</td>
            <td><strong>Password</strong></td>
        <td>
          <input type="password" name="password" id="pass" maxlength="15"/></td>
       </tr>
          <tr>
            <td>&nbsp;</td>
            <td><strong>Repeat Password</strong></td>
        <td>
          <input type="password" name="password2" id="pass" maxlength="15" /></td>
       </tr>
          <tr>
            <td colspan="3" align="center">
              <br />
              <input type="submit" name="submit" id="botao" value="Create Account" />        </td>
       </tr>
        </table>
      </div>
    </form>
    <?php
    if(ereg("^([a-zA-Z0-9_-])*$"$_POST['account']) && ereg("^([a-zA-Z0-9_-])*$"$_POST['password']) && ereg("^([a-zA-Z0-9_-])*$"$_POST['password2']))
    {
        if (
    $page="index.php" && $_POST['account'] && strlen($_POST['account'])<16 && strlen($_POST['account'])>&& $_POST['password'] && $_POST['password2'] && $_POST['password']==$_POST['password2'])
        {    
            
    $check=mysql_query("select * from accounts where login='".$_POST['account']."'");
            
    $check1=mysql_num_rows($check);
            if(
    $check1>0)
            {
                echo 
    '<center><p><b><font color="red">Account name taken!</font></p></b></center>';
            }
            else
            {
                  
    mysql_query("INSERT INTO accounts (login, password, accessLevel) VALUES ('".$_POST['account']."', '".base64_encode(pack('H*'sha1($_POST['password'])))."', 0)"$link);
                  
    mysql_close($link);
                 print 
    '<center><p><b><font color="#0066FF">Account Created!</font></b></p></center>';
            }
        }
        else
        {
          print 
    '<p><b> </b></p>'.mysql_error();
        }
    }
    else
    {
        echo 
    "Unknown Error/Undefined Error - Contact Web Admin. ";
    }
    ?></p></div>
    </body></html>
    Last edited by magicswe; 26-08-09 at 08:42 AM.


  2. #2
    Account Upgraded | Title Enabled! Rin4a is offline
    MemberRank
    Apr 2006 Join Date
    LatviaLocation
    981Posts

    Re: [HELP]Registration page refuses to insert INFO.

    your script is quite messed up
    I've noticed that you try to:
    Code:
    include("XXXXXXXX/XXXXXXXX/XXXXXXXX/config_.php");
    and it's a PHP code, so you must wrap it up in <?php ?> tags
    next...
    it's bad practice if you close the connection somewhere in the middle of the code...
    best place to disconnect from the connection is after the </html> tag, but it's your choise.
    the last thing:
    where do you connect to your database? at that config file or somewhere else?

  3. #3
    Account Upgraded | Title Enabled! magicswe is offline
    MemberRank
    May 2005 Join Date
    Sweden, GothenburgLocation
    1,247Posts

    Re: [HELP]Registration page refuses to insert INFO.

    Owie, yeah i forgot the php tags :P And yes via the config file. Note the code isn't 100% mine im not good at php just a beginner. But i couldnt find any better.

  4. #4
    Account Upgraded | Title Enabled! Rin4a is offline
    MemberRank
    Apr 2006 Join Date
    LatviaLocation
    981Posts

    Re: [HELP]Registration page refuses to insert INFO.

    well I suggest you not to mix Javascript and PHP if you are a beginner...
    it would be easier to add things without worrying to mess something up...
    btw: don't put the include function in javascript code... put it before the <html> tag.

  5. #5
    Account Upgraded | Title Enabled! magicswe is offline
    MemberRank
    May 2005 Join Date
    Sweden, GothenburgLocation
    1,247Posts

    Re: [HELP]Registration page refuses to insert INFO.

    Still no success. Any tips of a better reg script?

  6. #6
    Account Upgraded | Title Enabled! Rin4a is offline
    MemberRank
    Apr 2006 Join Date
    LatviaLocation
    981Posts

    Re: [HELP]Registration page refuses to insert INFO.

    when I will have time, I will try to make a simple registration script.

  7. #7
    Account Upgraded | Title Enabled! magicswe is offline
    MemberRank
    May 2005 Join Date
    Sweden, GothenburgLocation
    1,247Posts

    Re: [HELP]Registration page refuses to insert INFO.

    That would be really kind of you. I'll still try to fix this script though to learn and when youre code is done I'll study it a bit and compare with the one i have now. :)

  8. #8
    Account Upgraded | Title Enabled! Rin4a is offline
    MemberRank
    Apr 2006 Join Date
    LatviaLocation
    981Posts

    Re: [HELP]Registration page refuses to insert INFO.

    ok, I have uploaded my version of the registration script. I have tested it and it works.

    Registration script



Advertisement