login - php - Log In cannot detect mysqli_num_rows() but logs in anyway -
the code supposed echo specific things in html elements if log in successful
the problem this...once log in, shows page says "that user not exist or not yet activated, press back". when press "back" button on browser, shows me html elements supposed generate when log in successful.
"that user not exist or not yet activated, press back" supposed show when query turns out empty or not 1 @ least.
here code reference:
<?php include_once("check_login_status.php"); // initialize variables page might echo $e = ""; $joindate = ""; $lastsession = ""; // make sure _get email set, , sanitize if(isset($_get["em"])){ $e = $_get["em"]; // echo $e; } else { header("location: http://www.yoursite.com"); } // select member users table $sql = "select * user email='$e' , active='1' limit 1"; $user_query = mysqli_query($db_connect, $sql); // make sure user exists in table $numrows = mysqli_num_rows($user_query); // echo $numrows; if( $numrows != 1 ){ echo "that user not exist or not yet activated, press back"; exit(); } // check see if viewer account owner $isowner = "no"; if($e == $log_email && $user_ok == true){ $isowner = "yes"; } // fetch user row query above while ($row = mysqli_fetch_array($user_query, mysqli_assoc)) { $profile_id = $row["id"]; $signup = $row["signup"]; $lastlogin = $row["lastlogin"]; $joindate = strftime("%b %d, %y", strtotime($signup)); $lastsession = strftime("%b %d, %y", strtotime($lastlogin)); } ?> <!doctype html> <html> <head> <meta charset="utf-8"> <title><?php echo $u; ?></title> <link rel="icon" href="favicon.ico" type="image/x-icon"> <link rel="stylesheet" href="style.css"> <script src="main.js"></script> <script src="ajax.js"></script> </head> <body> <div id="pagemiddle"> <h3><?php echo $e; ?></h3> <p>is viewer page owner, logged in , verified? <b><?php echo $isowner; ?></b></p> <p>join date: <?php echo $joindate; ?></p> <p>last session: <?php echo $lastsession; ?></p> </div> </body> </html> i have made few echo tests , seems in separate test...
include_once("db_connect.php"); $e = "my email"; $sql = "select * user email='$e' , active='1' limit 1"; $user_query = mysqli_query($db_connect, $sql); // make sure user exists in table $numrows = mysqli_num_rows($user_query); echo $numrows; numrows echos out '1' - whereas in main code, numrows echoes out ()...which quite weird since $_get["em"] same email when checked via echo.
which quite weird since ...
no, it's not wired, problem not there!
i don't see error error in php:
include_once("check_login_status.php"); or not db connected
$user_query = mysqli_query($db_connect, $sql); enable error log in php.ini (see http://php.net/manual/it/errorfunc.configuration.php):
log_errors = on
and check error in apache (or else) web server logs.
or try not re-invent "hot water" , use done user management class:
Comments
Post a Comment