0

Hi there, help me from this code ,it skips "if" statement and execute "else "statement, whenever I run.

?php //require 'base.php'; $server="localhost"; $b='school_office'; try{ $c = new PDO("mysql: host= $server ; dbname=$b",'root',''); } catch(PDOException $e){ die('connection fail'. $e->getMessage()); } if (!empty($_POST['email']) && !empty($_POST['password'])){ //$sql= "SELECT id, email, password FROM teacher WHERE email = ':email "; $stmt = $c->prepare("SELECT id, email, password FROM teacher WHERE email = '$email' "); $stmt->bindParam('$email',$_POST['email']); $stmt ->execute(); $result = $stmt->fetch(PDO::FETCH_ASSOC); if(count($result ) > 0 && password_verify($_POST['password'],$result['password'])){ die('we have login'); }else{ die('error'); } } ?> <html> <head></head> <body> <h1> login here</h1> <form method = "POST"> <BR> <label>Enter email:</label><input type = "email" name = "email"> <BR> <BR> <label>Enter Password:</label><input type = "password" name = "password"> <BR> <BR> <input type = "submit" name = "submit"> </form> </body> </html>

15th Nov 2017, 11:56 PM
HAZZAN
HAZZAN - avatar
2 Antworten
+ 7
The js code should run when the user submits the form, not when the program starts. So make it a function and add the onsubmit event attribute to the form tag. The value should be the function name followed by parentheses.
16th Nov 2017, 12:05 AM
qwerty
qwerty - avatar
0
Let me do that
16th Nov 2017, 12:29 PM
HAZZAN
HAZZAN - avatar