Registration Form check PostgreSQL is username is already taken
Hey I'm really new to PHP and PostgreSQP or any database in that matter. So I'm at a loss how to do this.
I need an if statement that says.
If(the username user just typed in is already in database) {
my code here
}
the var开发者_如何转开发iable the username that the user just typed in is $userNameSignup
how would I do that with PHP for PostgreSQL?
also how might I redirect people to a new page once they have completed the form properly?
Thanks Shelby
ini_set('error_reporting', E_ALL);
ini_set('display_errors', 1);
$result = pg_query('SELECT 1 FROM logins WHERE LOWER(userName)=\''.strtolower(pg_escape_string($userNameSignup)).'\'') or exit(pg_last_error());
if (pg_num_rows($result)) {
$userNameSignupError = 'Username already taken please choose a new one.';
}
finally figured it out ^.^
精彩评论