Search the Community
Showing results for tags 'php pdo loginform'.
-
recently i changed my password for my mysql DB and after that the class method for the login form seems to be not working pl help me. And it doesn't throw up any errors too. the code in dbconfig.inc.php where the class is initiated is as follows: <?php session_start(); $host="localhost"; $dbName="project"; $dbUname="root"; $dbPass="*****"; try { $conn=new PDO("mysql: host=$host;dbname=$dbName; charset=utf8", $dbUname, $dbPass); $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); } catch (PDOException $e) { $e->getMessage(); } require_once 'classes.inc.php'; $project= new projecteg($conn); the login logic script page is as follows:(i tried to var_dump user its not working) <?php include_once 'dbconfig.inc.php'; if (isset($_POST['submit-login'])) { $uname= htmlentities($_POST['unamel']); $unamel= stripslashes($uname); echo "$unamel"; $pass= htmlentities($_POST['passl']); $pass1= stripslashes($pass); echo $pass1; $passl= md5($pass1); $user = $project->viewProtectedArea($unamel,$passl); print_r($user); if (isset($user)) { $_SESSION['id']=$user['user_id']; $_SESSION['fname']=$user['fname']; $_SESSION['lname']=$user['lname']; $_SESSION['uname']=$user['uname']; $_SESSION['email']=$user['email']; $_SESSION['phone']=$user['phone']; $_SESSION['app']=TRUE; $user_ok=TRUE; header("location: ../home.php?u={$_SESSION['uname']}"); } else { header("location: ../index.php?nosession"); } } /* if (isset($_SESSION['app'])&&$_SESSION['uname']!="") { header("location: ../home.php?u=".$_SESSION['uname']); } else { header("location: ../index.php?usernotfound?id=017"); } */ the class method logic is as follows: public function viewProtectedArea($unamel,$passl) { try { $active='1'; $stmth= $this->_db->prepare("select * from user where uname=:uname and pass=:pass and activated={$active}"); $stmth->bindparam(":uname",$unamel); $stmth->bindparam(":pass",$passl); $stmth->execute(); return $stmth->fetch(PDO::FETCH_ASSOC); } catch (PDOException $exc) { $exc->getMessage(); return false; } }