php - How come my SESSIONS aren't saving? -
<html> <head lang="en"> <meta charset="utf-8"> <link type="text/css" rel="stylesheet" href="bootstrap-3.2.0-dist\css\bootstrap.css"> <title>admin login</title> </head> <style> .login-panel { margin-top: 150px; </style> <body> <div class="container"> <div class="row"> <div class="col-md-4 col-md-offset-4"> <div class="login-panel panel panel-success"> <div class="panel-heading"> <h3 class="panel-title">sign in</h3> </div> <div class="panel-body"> <form role="form" method="post" action="admin_login.php"> <fieldset> <div class="form-group" > <input class="form-control" placeholder="name" name="admin_name" type="text" autofocus> </div> <div class="form-group"> <input class="form-control" placeholder="password" name="admin_pass" type="password" value=""> </div> <input class="btn btn-lg btn-success btn-block" type="submit" value="login" name="admin_login" > </fieldset> </form> </div> </div> </div> </div> </div> </body> </html> <?php include("database/db_conection.php"); if(isset($_post['admin_login']))//this tell if data has been post through form button. { $admin_name=mysqli_real_escape_string($dbcon, $_post['admin_name']); $admin_pass=mysqli_real_escape_string($dbcon, $_post['admin_pass']); $admin_query="select * users user_name='$admin_name' , user_pass='$admin_pass' , admin='true'"; $run_query=mysqli_query($dbcon,$admin_query); if(mysqli_num_rows($run_query)) { echo "<script>window.open('welcome.php','_self')</script>"; $_session['adminname']=$admin_name; $_session['isadmin']='true'; } else {echo"<script>alert('admin details incorrect..!')</script>";} } ?>
that admin_login.php
page, , inside db_connection.php
code connect users database
i have tried putting session variables above echo welcome.php
, not worked.
in case still confused, $_session['adminname']=$admin_name;
, $_session['isadmin']='true';
not setting correctly, , have no clue why.
you have call function
session_start();
somewhere before using $_session
globals. here's documentation it!
Comments
Post a Comment