开发者

Registration Form check PostgreSQL is username is already taken

开发者 https://www.devze.com 2022-12-23 15:41 出处:网络
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.

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 ^.^

0

精彩评论

暂无评论...
验证码 换一张
取 消