I have inherited a php postgresql site problem.
It requires a unique username for a members section.
When someone runs the script it does not stop when the database shows that the username is taken and insert the username value and then shows the user that the username is taken ??? I really need a response. end or something. to stop the script cold if the username is taken.
See code below:
********************************************************************************/
$sqlstr = "SELECT id FROM users WHERE login = '".$login."'";
$result = query($sqlstr);
if (num_rows($result) != 0) {
if ($html) { header("Location: /html/$lang/reg_error6.html"); die();} else { die ("error=".urlencode("login already taken.")); }
}
/********************************************************************************
insert the new user into the db
********************************************************************************/
$HTTP_SESSION_VARS["login"]=$login;
$sqlstr = "INSERT INTO users (firstname, middlename, lastname, email,age, sex, ";
$sqlstr .= "language, country, userlevelid, login, password) ";
$sqlstr .= "VALUES ('$firstname', '$middlename', '$lastname','$email', '$age', '$sex',";
$sqlstr .= "'$language', '$country', '$userlevelid', '$login', '$password')";
$result = query($sqlstr);
$senderId = get_userid($login); // get the newly inserted user's id # (confusing var name here)
if (!$result) die ("error=".urlencode('cant add user to db')); //error-handle in case INSERT failed