Directing user to a page or another (PHP and MysQL) -
i creating site invited users directed register once email validated against master list of users , (2) returning users directed different page once validated against master list of users. master list of users have email addresses invited users. upon registration, users enter rest of information, including first name (fname).
what need piece of code check if first name null, if direct user "registration.html"; whereas if first name present user user should directed "overview.html".
my code not working properly, regardless of fname being null or xyz users directed "overview.html".
$query = "select email, fname registration email='$email'"; if (fname = "null") { header('location: registration.html'); } else { header('location: overview.html'); }
thanks help!
i'm assuming didn't paste whole code here. how did fetch row?
one thing can point out though, in php = assignment.you want use == comparison operator.
also, unquote "null", you're comparing string 'null'.
hope solves it.
edit: seeing other comments, here's code should like, assuming have email stored in variable called $email , pdo connection stored in $dbc.
$q = "select email, fname registration email = ?"; $stmt = $dbc->prepare($q); $stmt->execute(array($email)); if($stmt->rowcount() == 1){ //you have unique email accounts $row = $stmt->fetch(); if (is_null($row['fname'])) { header('location: registration.html'); } else { header('location: overview.html'); } }
Comments
Post a Comment