Jump to content

HuuD

Members
  • Content Count

    11
  • Joined

  • Last visited

Community Reputation

0 Neutral

About HuuD

  • Rank
    Member
  1. This issue is resolved, I had an If condition on session in login page which I removed and its working on both pages now..
  2. This is what is happening now... The login and registration pages are linked to a single booking page. When I login the session variable is NOT received by the booking page but when I register the variable session is received by the booking page and shows user logged. Thank..
  3. Thanks for pointing out, I had a single point of data retrieval from db and validation, but it was not working as it should have so I took this from another place.. Anyway I found the issue was my implementation and NOT related to password encryption as pointed out above... I was using a while loop which was causing the variables to change, so I changed the while loop to an if condition and removed $row and added a variables to receive the values, working fine and authenticating... Thanks..
  4. Thanks for pointing out, I had a single point of data retrieval from db and validation, but it was not working as it should have so I took this from another place to test it..
  5. Apologies, Im not a hard programmer, so if you could explain in some simple english... The session variable value echoes fine so storage is not an issue, but when I try to echo it on the next page it shows this error, I did a lot of reading followed accordingly but still the issue persists... Should I post the whole code ?
  6. Hi, To verify issues, I removed password altogether and the session variable still does not get set, still the new page does not receive the session variable..
  7. Hi All, I have this issue where the PHP session stored in one page is not received in the new page, I have set the session_start(); at the very top of all the pages the page and funnily there is no error but the data does not show on the new page, please find the code below as Im not able to understand whats going wrong here, Thanks. I CAN ADD THE FULL CODE, BUT ITS TOO LENGHTY. Also is there a simple PHP debugger as the xDebug does not work I have tried several methods... The error I receive : Notice: Undefined index: sesName in D:\Softwares\Xampp\htdocs\book\booking.php on line 3 But when I check the the echo of the session in the page that priginated, there is data, also note that all the 3 codes below are from different pages. Session data sending page : while ($row = mysqli_fetch_assoc($result)) { $dbemail = $row["email"]; $dbpass = $row["password"]; } if(($lemail == $dbemail) && ($lpass == password_verify($lpass, $dbpass))) { $_SESSION['sesName'] = $dbemail; echo $_SESSION['sesName']; header("Location:booking.php"); Session data receiving page : <?php session_start(); echo $_SESSION['sesName']; ?> <!DOCTYPE html> <html lang="en"> <body id="admin"> <head> <link href="css/bootstrap.min.css" rel="stylesheet"> <link href="css/datepicker3.css" rel="stylesheet"> <link href="css/styles.css" rel="stylesheet"> </head> <body> <div class="row"> <div class="col-xs-10 col-xs-offset-1 col-sm-8 col-sm-offset-2 col-md-4 col-md-offset-4"> <div class="login-panel panel panel-default"> <div class="panel-heading"><p class="text-center">CABSONLINE</p></div> <div class="panel-heading"> <?php if (empty($_SESSION['sesName'])) { echo '<span class="label label-danger center-block">YOU ARE NOT LOGGED IN, REDIRECTING TO LOGIN PAGE..</span></h3>'; echo "<meta http-equiv='refresh' content='4;url=login.php'>"; } else { echo '<h5>' . $_SESSION['sesName'] . ' IS LOGGED IN, FILL IN THE DETAILS AND BOOK A CAB</h5>'; } ?>Page destroying the session : if (isset($_POST['logout'])) { session_unset(); session_destroy(); header("location:index.html");
  8. Thanks for taking the time out, will follow as instructed..appreciate it..
  9. I believe you missed the password_verify() which hashes and compares hashed passwords..
  10. HI, I hvae this code of php which shoes nothing in the div of bootstrap CSS, it shows empty div instead of text, any hints what I could be doing wrong. <?php if (isset($_SESSION['sesName'])) {/* THIS DIV IS CREATED IF THE SESSION EXISTS AND SHOULD SHOW THE USER NAME AND WELCOME MESSAGE BUT NOTHING HAPPENS echo '<div class="row"> <div class="col-xs-10 col-xs-offset-1 col-sm-8 col-sm-offset-2 col-md-4 col-md-offset-4"> <div class="panel-body"> <form role="form"> <fieldset> <div class="form-group">'; echo '<div class = "alert alert-success fade in">Welcome ' . $_Session['sesName'] . '"</div>'; '</div> </fieldset> </form> </div> </div> </div>'; } ?> <div class="row"> <div class="col-xs-10 col-xs-offset-1 col-sm-8 col-sm-offset-2 col-md-4 col-md-offset-4"> <div class="login-panel panel panel-default"> <div class="panel-heading">LOGIN</div> <div class="panel-body"> <form role="form" method="POST" action=""> <fieldset> <div class="form-group"> <input class="form-control" placeholder="E-mail" name="lemail" type="text" autofocus=""> </div> <div class="form-group"> <input class="form-control" placeholder="Password" name="lpass" type="password" value=""> </div> <div class="checkbox"> </div> <input type ="submit" class="btn btn-primary" value="LOGIN"> <input type ="button" onclick="location.href='registration.php'" class="btn btn-primary" value="REGISTRATION"> </fieldset> </form> </div> </div> </div> </div>
  11. Hi all, I have the below code and the issue is I'm trying to validate the login/password of user from mysql and there seems to be this issue where ONLY if the email match was found in the db and the password was WRONG the error message shows up, if the email was not found in the db, even though I have set an error message it does not show. <?php session_start(); $server = "localhost"; $user = "root"; $pwd = ""; $sql_db = "cabcustomers"; $lname = isset($_POST['lemail']); $lpass = isset($_POST['lpass']); $dbname; $conn = @mysqli_connect($server,$user,$pwd,$sql_db); if (!$conn) { die("Connection to Database has failed: " . mysqli_connect_error()); } if (isset ($_POST["lemail"]) && isset ($_POST["lpass"])) { $lemail = $_POST["lemail"]; $lpass = $_POST["lpass"]; $query = "select email, password from customer where email='$lemail' and password = '$lpass'"; $result = mysqli_query($conn, $query); if ($row = mysqli_fetch_assoc($result) > 0) { $dbname = $row["email"]; $dbpass = $row["password"]; $passchk = password_verify($lpass, $dbpass); if ($lemail == $dbname && $passchk == $dbpass) { $_SESSION['sesName'] = $dbname; header('location:booking.php'); } else { /*THIS PART FAILS AS THIS ERROR ONLY SHOWS IF THE EMAIL EXISTS AND THE PASSWORD AND DOES NOT SHOW IF NO MATCH WAS FOUND echo '<div class="row"> <div class="col-xs-10 col-xs-offset-1 col-sm-8 col-sm-offset-2 col-md-4 col-md-offset-4"> <div class="panel-body"> <form role="form"> <fieldset> <div class="form-group">'; echo '<div class = "alert alert-danger alert-dismissable fade in"><button type = "button" class = "close" data-dismiss = "alert" aria-hidden = "true">×</button>This email is not registered or the password is incorrect, please try again or consider registering</div> </div> </fieldset> </form> </div> </div> </div>'; } } elseif (empty($lemail) || empty($lpass)) { echo '<div class="row"> <div class="col-xs-10 col-xs-offset-1 col-sm-8 col-sm-offset-2 col-md-4 col-md-offset-4"> <div class="panel-body"> <form role="form"> <fieldset> <div class="form-group">'; echo '<div class = "alert alert-info alert-dismissable fade in"><button type = "button" class = "close" data-dismiss = "alert" aria-hidden = "true">×</button>No email or password entered</div>'; '</div> </fieldset> </form> </div> </div> </div>'; } } mysqli_close($conn); ?> Thank You All for your help.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.