$sql = 'SELECT * FROM tbluser, tblfile WHERE tbluser.Username = "'.$user.'"';
if ($result = mysql_query($sql)) {
if(mysql_num_rows($result)) {
echo'User already exists';
exit;
}
else
{
mysql_query('INSERT INTO tbluser
(`Username`, Password, BossID) VALUES ( "'.$user.'","'.$passwd.'","'.$boss.'")')or die(mysql_error());
$sqlq = 'SELECT * FROM tbluser, tblfile WHERE tbluser.Username = "'.$user.'"';
$res = mysql_query($sqlq);
while($row = mysql_fetch_array($res)){
mysql_query('INSERT INTO tbluser_file
(`FileID`, UserID) VALUES ( "'.$row['FileID'].'","'.$row['UserID'].'")')or die(mysql_error());
}
echo "Admin Added!";
}
}
I would like to check if a user already exists in my database. If he exists I want to exit, if he doesn't exist, i would like to execute above code (under the ELSE statement)
thanks in advance