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);
}
}