Search the Community
Showing results for tags 'php mysql pdo'.
-
Hi all, I am wondering how to get this to work or if it is possible. I have an application that was not built with the admin having access to all the users account but now i want it to have access to all accounts. Thanks. (though i've not tried anything yet, just dont know how to start and i dont want to start afresh: advice) My current login code is: <?php if(isset($_POST['login'])){ $username = stripslashes($_POST['username']); $password = stripslashes($_POST['password']); $stmt = $pdo->prepare("SELECT password FROM tablename WHERE username=:username"); $stmt->bindValue(':username', $username, PDO::PARAM_STR); $stmt->execute(); if($stmt->rowCount()<1){ echo '<div class="signals"><p class="bg-warning text-center warning"><button type="button" class="close" aria-label="Close"><span aria-hidden="true">×</span></button>INVALID USERNAME OR PASSWORD</div></p>'; }else{ list($hash) = $stmt->fetch(PDO::FETCH_NUM); if (password_verify($password, $hash)) { //$_SESSION['username'] = $username; $status1 = "COMPLETED"; $status2 = "PROCESSING"; //$stmt = $pdo->query("SELECT status FROM ca_confirmed WHERE username ='$_SESSION[username]'"); $stmt = $pdo->query("SELECT status FROM tablename WHERE username ='$username'"); $check = $stmt->fetch(PDO::FETCH_ASSOC); $status = $check['status']; $_SESSION['username'] = $username; if(strcmp($status, $status1) == 0){ header("location: completed/index.php"); exit(); }elseif(strcmp($status, $status2) == 0){ header("location: uncompleted/index.php"); //exit(); } }else{ echo '<div class="signals"><p class="bg-warning text-center warning"><button type="button" class="close" aria-label="Close"><span aria-hidden="true">×</span></button>INVALID USERNAME OR PASSWORD again</div></p>'; } } } ?>