mysql - Problems updating current user information PHP PDO -
i'm working on user profile system... i'm stuck @ stage user updates information. i'm checking whether users newly chosen email address exists in database. i'm echoing out current email address input value in form.
the validation error received preventing user updating other information if email remains same in db.... guidance appreciated.
$signedin = $_session['username']; function userexists($db, $email) { $userquery = "select * members email = '$email' , email != '$signedin'"; $stmt = $db->prepare($userquery); $stmt->execute(array(':email' => $email)); return !!$stmt->fetch(pdo::fetch_assoc); } $email = $_post['email']; $exists = userexists($db, $email); if($exists) { header("location: memberaccount.php?action=email_in_use"); } else { //submit form data
where start?
- you're putting variables right query
- you not use markers
- although 2, trying bind value marker
looks not understand pdo about.
the right code this:
$userquery = "select * members email = :email , email != :signedin"; $stmt = $db->prepare($userquery); $stmt->execute(array(':email' => $email, ':signedin' => $signedin));
and eludes me why using !!
when return:
return !!$stmt->fetch(pdo::fetch_assoc);
should just
return $stmt->fetch(pdo::fetch_assoc);
i advice on reading how prepared statements work
Comments
Post a Comment