register

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
User avatar
sguy
Forum Commoner
Posts: 61
Joined: Sun Aug 10, 2003 2:44 am

register

Post by sguy »

what problem with tihs code?
this is a register code, i have 2 tables, account & account1, if i register a user, i don't want the 2 tables have the same username

Code: Select all

$mysql_access = mysql_connect("localhost", "root", "");
        mysql_select_db("db");
  
        check == 0;
        $result = mysql_query("select * from account");
        $number_of_rows = mysql_num_rows($result);
        $i=0;
        $check=0;
        while ($number_of_rows != 0)
             {
                 $row =  mysql_fetch_row($result);
                 $number_of_rows--;
                 if ($username==$row[0])
                    {
                    echo "<center><br><br><br><font size = 4 color = #003366>Invalid username <BR>Currently the username has been used!!<br>";
                    echo "<BR>Click <a href="register_username.php">here</a> to try again !!<br>";
                    exit;
                    }
                    else
                    {
                    $query = "INSERT INTO account (username, password) values ('$username', '$password')";
                    mysql_query($query, $mysql_access);
                    }
             }

	check == 0;
        $result = mysql_query("select * from account1");
        $number_of_rows = mysql_num_rows($result);
        $i=0;
        $check=0;
        while ($number_of_rows != 0)
             {
                 $row =  mysql_fetch_row($result);
                 $number_of_rows--;
                 if ($username1==$row[0])
                    {
                    echo "<center><br><br><br><font size = 4 color = #003366>Invalid username <BR>Currently the username has been used!!<br>";
                    echo "<BR>Click <a href="register_username.php">here</a> to try again !!<br>";
                    exit;
                    }
                    else
                    {
                    $query = "INSERT INTO account (username, password) values ('$username', '$password')";
                    mysql_query($query, $mysql_access);
                    }
             }
User avatar
JAM
DevNet Resident
Posts: 2101
Joined: Fri Aug 08, 2003 6:53 pm
Location: Sweden
Contact:

Post by JAM »

What should it be then?
Post Reply