Parse Error on isset? [PHP] -
i'm quite new http/php coding , i'm having little trouble isset
in php. current code below, it's supposed check if username , password admin , password, if so, echo them info.
however, doesn't work. there no errors, accepts usernames , passwords.
$username = isset($_post['password']); $password = isset($_post['username']); $date = date('d-m-y'); $time = date('h:m:s'); $day = date('l'); if($username == 'admin' , $password == 'password') { //echo bla bla bla..
isset
checks if variable set. usercase, on otherhand, needs check actual values:
if(isset($_post['username']) , $_post['username'] == 'admin' , isset($_post['password']) , $_post['password'] == 'password') { // echo...
in order use isset()
being passed in variable(s) have now, need use ternary operator.
i.e.:
$username = isset($_post['password']) ? $_post['password'] : "default";
- consult example #3 , others on
http://php.net/manual/en/language.operators.comparison.php
Comments
Post a Comment