php - log in system with sessions and mysqli done something wrong -
hello guys trying make simple log-in system school project, got work when didn't implement database. can see tried implement database don't work since can't make php tags @ start , end of echo's, anyway can me out? said worked when wrote random username , password, , didn't have database thing on it.
<?php session_start(); include('../inc/dbconnection_inc.php'); $result=mysqli_query($dbconnection, 'select * users'); $row=mysqli_fetch_array($result); $p=$_post['password']; $u=$_post['username']; if ($u==echo $row["username"] , $p==echo $row["password"]); { $_session['username'] = echo $row["username"]; header("location: admin.php"); } else { header("location: ../index.php"); }
i not sure need echo
there. according manual, echo returns nothing.
try removing echo
's code, like
... if ($u === $row["username"] && $p === $row["password"]) { $_session['username'] = $row["username"]; header("location: admin.php"); }
(also use &&
instead of and
, cause)
besides code check first fetched row (i think you're aware of that?)
Comments
Post a Comment