php - session in login framework -
for school making login system. next step when user logged in button 'log out' wil appear on every page. know have $_session don't know how use in code. hope can me out?!
loginmodel:
function loginuser($username = null, $password = null){ $username = $_post["username"]; $password = $_post["password"]; $db = opendatabaseconnection(); $result1 = $db->prepare("select * login username = '$username' , password = '$password'"); $result1->execute(); if($result1->rowcount() > 0 ) { $_session['logged in'] = true; $_session['username'] = $username; $db = null; return true; } else { $db = null; return false; }
}
logincontroller:
function login(){ if(isset($_post["username"]) && isset($_post["password"])) { if(loginuser($_post['username'], $_post['password'])) { header("location:" . url . "login/index"); }else{ render("login/login"); echo 'ownee het een fout help'; } } else { render("login/login"); } }
Comments
Post a Comment