php - How to check if something is fetched , and then to run multiple query -
i've searching quite time no luck. want check if given username , password correct echo something, it's not working. after want run query.
<?php require "conn.php"; $status=1; $user_name = $_post["user"]; $user_pass = $_post["pass"]; $sql = "select * tbl_client username = :user , password = :pass"; $sth = $dbl->prepare($sql); $sth->execute(array(':user => $user_name' , ':pass => $user_pass' )); //$sth->execute(':user' => $user_name, ':pass' => $user_pass); $row = $sth->fetch(pdo::fetch_num); if ($row) { echo 'login success , hello'; } else { echo 'login failed'; } $sql = 'insert login_status (username, status) values (:user, :status)'; $sth = $dbl->prepare($sql); $sth->execute(array(':user => $username' , ':status => $status' )); ?>
$sth->execute(array(':user => $username' , ':pass => $user_pass' ));
that wrong! array contains 2 strings should contain 2 key-value pairs (key = parameter in sql query, value = want pass database driver)
try this
$sth->execute(array(':user' => $username , ':pass' => $user_pass ));
Comments
Post a Comment