PHP MYSQL login script session not working -


i have small script deal login in cms. query works fine, think have problem sessions, because redirects login page when username , password correct. have codes below. kindly me resolve this. in advance.

//checklogin.php....

<?php include("db/dbconnect.php");  mysqli_select_db($connect, $db);  // username , password sent signup form $username = mysqli_real_escape_string($connect, $_post['username']); $password = mysqli_real_escape_string($connect, $_post['password']);  $sql = "select username, password login username = '$username' , password = '$password'"; $result = mysqli_query($connect, $sql) or die('error : ' .  mysqli_error($connect));  // mysql_num_row counting table row $count = mysqli_num_rows($result);  // if result matched $username , $password, table row must 1 row if($count == 1) {      //register $username, $password , redirect mainpage"     $_session['username'] = $username;     $_session['password'] = $password;      header("location:about.php"); } else { echo "invalid username or password. please try again."; echo "<meta http-equiv=refresh content=5;url=index.php>"; } ?> 

//about.php

<?php  //check if user logged on; session_start(); if(!isset($_session['username']) ) {     header("location:index.php"); } ?> 

add session_start(); in checklogin.php you

<?php  session_start();  //missing in checklogin.php include("db/dbconnect.php"); mysqli_select_db($connect, $db); 

Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -