javascript - PHP PDO SESSION not able to redirect -


i using session through login form , when trying login not redirecting index.php . please let me know mistaken. below code index , login

         <?php           session_start();             if (!isset($_session['user_name'])) {             header("location: login.php");              }              else{               echo "welcome $user_name";              ?> 

following html

<!doctype html>  <html>  <head>  	<title>admin panel</title>  	<link rel="stylesheet" type="text/css" href="admin_style.css">  </head>  <body>    <h1>welcome home page</h1>    </body>  </html>

           <?php } ?> 

below login.php code form

            <?php              session_start();             ?> 

<!doctype html>  <html>  <head>  	<title>admin login</title>  </head>  <body>  <form action="login.php" action="post">  	<table width="400" align="center" border="20">    	<tr>  		<td colspan="5" align="center" bgcolor="gray"><h1>admin login</h1></td>  	</tr>    	<tr>  		<td align="right">user name:</td>  		<td><input type="text" name="user_name"></td>  	</tr>    	<tr>  		<td align="right">user password</td>  		<td><input type="password" name="user_pass"></td>  	</tr>    	<tr>  		<td align="center" colspan="5"><input type="submit" name="login" value="login"></td>  		  	</tr>  		  	</table>  </form>    </body>  </html>

    <?php  include("connect.php");  if(isset($_post['login'])) {      $user_name = $_post['user_name'];     $user_pass = $_post['user_pass'];      $sth = $con->prepare("select * admin_login user_name='$user_name' , user_password='$user_pass'");        $sth->execute();       if($sth->rowcount() > 0) {          $_session['user_name'] = $user_name;         header("location: index.php"); // redirecting index page         } else {        echo "<script>alert('username or password invalid')</script>";        }    }   ?> 

through code able see on address bar line , no javascript alert: http://localhost/malala/admin/login.php?user_name=kitchen&user_pass=kitchen&login=login

please ....

http://localhost/malala/admin/login.php?user_name=kitchen&user_pass=kitchen&login=login send variable get , you're looking them post


Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -