Register problem

02/16/2011 22:55 petje1#1
Hello,

I got a problem with my register script

Script:
PHP Code:

 <?php
    
if(isset($_POST['retpass']) && isset($_POST['id']) && isset($_POST['pass']))  {  
    if(!Empty(
$_POST['retpass']) && !Empty($_POST['id']) && !Empty($_POST['pass']))  {
          
$ok=false;
      if (
$requireCAPTCHA)  { if (PhpCaptcha::Validate($_POST['CheckCode'])) $ok=true; }
          else 
$ok=true;
          
            if(
$ok)    {
                
mysql_select_db($accdb);
                
$userid trim($_POST['id']);
                
$password=trim($_POST['pass']);
                
$passretype=trim($_POST['retpass']);
                
$hash=$_POST['hash'];
                
                
        if (!Empty(
$mail)) if (!ereg("^[0-9a-zA-Z]{4,128}$", (strtr($mail, Array('@'=>'','.'=>'')))))    {
                    
$mail='';
          echo 
'mail > Only letters a to z and special chars @ . are allowed';
                    }
        if(!
ereg("^[0-9a-z]{4,12}$",$userid))    {
                    echo 
'login > Only letters from "a" to "z" and numbers, lenght of 4 to 12 characters';
                    }
                else {
                    if(
$password == $passretype) {
                     if(!
ereg("^[0-9a-zA-Z]{4,22}$",$password))    {
                            echo 
'password > Only letters or numbers, lenght of 4 to 22 characters';
                            }
                        else    {
                            
$res mysql_query('SELECT * FROM accounts WHERE AccountID = "'.$userid.'" ORDER BY AccountID DESC');
                            if(
mysql_num_rows($res) == 0)    {
                            
mysql_query('INSERT INTO accounts(AccountID,Password) VALUES ("'

                  
.$userid.'","'.($passhash $hash $password).'","'
                  
.$_SERVER['REMOTE_ADDR'].'", "'.'255.255.255.0")');
                                echo 
'Success > Account registered successfully.';
                                }
                            else echo 
'Error > Account Already exists.';
                            }
                        }
                    else  echo 
'Passwords did not match.';
                    }
                }
            else  echo 
'Check Code is Wrong.';
            }
        else echo 
' umm why there is empty <b>required</b> areas in register form????';
        }
?>
This is the script somehow it says registration succes but it doesn't put anything in the database

Config file:

Code:
<?php
	$myhost='localhost';   // MySQL database address
	$mypass='lol'; 		   // MySQL server login
	$myuser='root'; 		   // MySQL server pass
	
	$accdb='accounts';         //your server account database
	$gamedb='coserver';
Tables in the accounts are called:

AccountID, Password, Status, Character, Email, SecretNumber

Got more info needed tell me then :3

Thx in advance x3
02/16/2011 23:11 HackProvider#2
Tell me if ya got it fixed got THE same prob
02/16/2011 23:15 petje1#3
Some 1 had fixed it for me but then i accedently deleted it D:

So hope some 1 wil help xD
02/17/2011 01:02 Mr_PoP#4
Quote:
Originally Posted by petje1 View Post

This is the script somehow it says registration succes but it doesn't put anything in the database

Tables in the accounts are called:
AccountID, Password, Status, Character, Email, SecretNumber
you said it's AccountID, Password, Status, Character, Email, SecretNumber then why in ur php is (AccountID,Password) only?!! :confused: where is the tables name to set the new value to? also u forgot the " "

PHP Code:
 mysql_query('INSERT INTO accounts(AccountID,Password) VALUES ("'
                  
.$userid.'","'.($passhash $hash $password).'","'
                  
.$_SERVER['REMOTE_ADDR'].'", "'.'255.255.255.0")'); 
ur php is not even close to be right coded -.- well this may work:
PHP Code:
 mysql_query('INSERT INTO "accounts" SET "AccountID"="'.$userid.'","Password"="'.($passhash $hash $password).'","Email"="'.$mail.'" '
thats all ur table can hase u cant set $_SERVER['REMOTE_ADDR'] or 255.255.255.0 to it , my code should work for u test it
02/17/2011 13:04 petje1#5
Im getting this error then

Code:
C:\AppServ\www\register.php on line 83
Code is now:

PHP Code:
<?php
    
if(isset($_POST['retpass']) && isset($_POST['id']) && isset($_POST['pass']))  {  
    if(!Empty(
$_POST['retpass']) && !Empty($_POST['id']) && !Empty($_POST['pass']))  {
          
$ok=false;
      if (
$requireCAPTCHA)  { if (PhpCaptcha::Validate($_POST['CheckCode'])) $ok=true; }
          else 
$ok=true;
          
            if(
$ok)    {
                
mysql_select_db($accdb);
                
$userid trim($_POST['id']);
                
$password=trim($_POST['pass']);
                
$passretype=trim($_POST['retpass']);
                
$hash=$_POST['hash'];
                
                
        if (!Empty(
$mail)) if (!ereg("^[0-9a-zA-Z]{4,128}$", (strtr($mail, Array('@'=>'','.'=>'')))))    {
                    
$mail='';
          echo 
'mail > Only letters a to z and special chars @ . are allowed';
                    }
        if(!
ereg("^[0-9a-z]{4,12}$",$userid))    {
                    echo 
'login > Only letters from "a" to "z" and numbers, lenght of 4 to 12 characters';
                    }
                else {
                    if(
$password == $passretype) {
                     if(!
ereg("^[0-9a-zA-Z]{4,22}$",$password))    {
                            echo 
'password > Only letters or numbers, lenght of 4 to 22 characters';
                            }
                        else    {
                            
$res mysql_query('SELECT * FROM accounts WHERE AccountID = "'.$userid.'" ORDER BY AccountID DESC');
                            if(
mysql_num_rows($res) == 0)    {
                            
mysql_query('INSERT INTO "accounts" SET "AccountID"="'.$userid.'","Password"="'.($passhash $hash $password).'","Email"="'.$mail.'" ')
                  .
$userid.'","'.($passhash $hash $password).'","'
                  
.$_SERVER['REMOTE_ADDR'].'", "'.'255.255.255.0")');
                                echo 
'Success > Account registered successfully.';
                                }
                            else echo 
'Error > Account Already exists.';
                            }
                        }
                    else  echo 
'Passwords did not match.';
                    }
                }
            else  echo 
'Check Code is Wrong.';
            }
        else echo 
' umm why there is empty <b>required</b> areas in register form????';
        }
?>
sorry lawl but i took this from a other dude hes register script o.o

and why you should import the character if they register an account? o.o i thougth it wasn't realy needed

edit:
this is what he says on line 83 o.o
Code:
								echo 'Success > Account registered successfully.';
02/17/2011 17:50 Mr_PoP#6
Quote:
Originally Posted by petje1 View Post
Im getting this error then

Code:
C:\AppServ\www\register.php on line 83
Code is now:

PHP Code:
<?php
    
if(isset($_POST['retpass']) && isset($_POST['id']) && isset($_POST['pass']))  {  
    if(!Empty(
$_POST['retpass']) && !Empty($_POST['id']) && !Empty($_POST['pass']))  {
          
$ok=false;
      if (
$requireCAPTCHA)  { if (PhpCaptcha::Validate($_POST['CheckCode'])) $ok=true; }
          else 
$ok=true;
          
            if(
$ok)    {
                
mysql_select_db($accdb);
                
$userid trim($_POST['id']);
                
$password=trim($_POST['pass']);
                
$passretype=trim($_POST['retpass']);
                
$hash=$_POST['hash'];
                
                
        if (!Empty(
$mail)) if (!ereg("^[0-9a-zA-Z]{4,128}$", (strtr($mail, Array('@'=>'','.'=>'')))))    {
                    
$mail='';
          echo 
'mail > Only letters a to z and special chars @ . are allowed';
                    }
        if(!
ereg("^[0-9a-z]{4,12}$",$userid))    {
                    echo 
'login > Only letters from "a" to "z" and numbers, lenght of 4 to 12 characters';
                    }
                else {
                    if(
$password == $passretype) {
                     if(!
ereg("^[0-9a-zA-Z]{4,22}$",$password))    {
                            echo 
'password > Only letters or numbers, lenght of 4 to 22 characters';
                            }
                        else    {
                            
$res mysql_query('SELECT * FROM accounts WHERE AccountID = "'.$userid.'" ORDER BY AccountID DESC');
                            if(
mysql_num_rows($res) == 0)    {
                            
mysql_query('INSERT INTO "accounts" SET "AccountID"="'.$userid.'","Password"="'.($passhash $hash $password).'","Email"="'.$mail.'" ')
                  .
$userid.'","'.($passhash $hash $password).'","'
                  
.$_SERVER['REMOTE_ADDR'].'", "'.'255.255.255.0")');
                                echo 
'Success > Account registered successfully.';
                                }
                            else echo 
'Error > Account Already exists.';
                            }
                        }
                    else  echo 
'Passwords did not match.';
                    }
                }
            else  echo 
'Check Code is Wrong.';
            }
        else echo 
' umm why there is empty <b>required</b> areas in register form????';
        }
?>
sorry lawl but i took this from a other dude hes register script o.o

and why you should import the character if they register an account? o.o i thougth it wasn't realy needed

edit:
this is what he says on line 83 o.o
Code:
								echo 'Success > Account registered successfully.';
upload ur php and a dumb of ur table
02/18/2011 12:22 BioHazarxPaul#7
Code:
mysql_query('INSERT INTO accounts(AccountID,Password) VALUES ("' . $userid . '","' . ($passhash ? $hash : $password) . '","' . $_SERVER['REMOTE_ADDR'] . '", "' . '255.255.255.0")');
I would of kept it that way but it looks like u need more then just AccountID and Password because you are storing data values into more then thos 2 sections.

Also just wondering but wouldn't accounts be your table and not your database?
02/18/2011 14:42 petje1#8
Its my account table

Where all the accounts are stored
anyway

here is the link to my config and register
[Only registered and activated users can see links. Click Here To Register...]
02/18/2011 15:06 BioHazarxPaul#9
$accdb='accounts'; - You need to fix that then it should be ur database not ur table.
02/18/2011 16:26 petje1#10
Like i explained later on.
My account Table is called:"accounts" where all the accounts are stored?

My normal database where all the tables are in is called coserver
02/19/2011 17:31 BioHazarxPaul#11
Quote:
Originally Posted by petje1 View Post
Like i explained later on.
My account Table is called:"accounts" where all the accounts are stored?

My normal database where all the tables are in is called coserver
okay so one of the problems i am seeing is
$accdb='accounts'; <- This need to be that -> $accdb='coserver';
in your config.php
02/19/2011 17:53 petje1#12
You dont get it do you?

wait i'll make a screenshot

[Only registered and activated users can see links. Click Here To Register...]

As you can see the config files are good...
02/19/2011 20:33 BioHazarxPaul#13
correct me if im wrong but accounts is just a table its in no way a database.
your $accdb needs to be coserver so it can connect to ur database then select accounts from the database maybe im just miss understanding ur php script wrong though Iv done mine a bit different
02/20/2011 00:54 petje1#14
What it does it first connects to the database then it needs the name of the Account table to get the accounts i'll think o.o

But could you make yours so it works on mine? cause i can't figure out the prob o.o

edit:

I tried changeing the config file but it does the same
There must be something wrong in the register script o.o
02/20/2011 02:23 stealarcher#15
#problem solved. Column count didnt match value count on the mysql insert.