shwetapandit Posted November 16, 2013 Share Posted November 16, 2013 the session var email is not saves as when ai am using if-else to check session isset it goes to else clause why it is so and how i can save my session. <?phpsession_start();$host="localhost"; // Host name$username="root"; // Mysql username$password=""; // Mysql password$db_name="regis"; // Database name$tbl_name="regis"; // Table name// Connect to server and select databse.mysql_connect("$host", "$username", "$password")or die("cannot connect");mysql_select_db("$db_name")or die("cannot select DB");// username and password sent from form$email=$_POST['email'];$pass=$_POST['pass'];// To protect MySQL injection (more detail about MySQL injection)$email = stripslashes($email);$pass = stripslashes($pass);$email = mysql_real_escape_string($email);$pass = mysql_real_escape_string($pass);$sql="SELECT * FROM $tbl_name WHERE email='$email' and pass='$pass'";$result=mysql_query($sql);// Mysql_num_row is counting table row$count=mysql_num_rows($result);// If result matched $email and $pass, table row must be 1 rowif($count==1){$_session['email']="$email"; else { echo "Wrong Username or Password";} if(isset($_SESSION['email']))echo "amit"; elseecho "other";} ?> Quote Link to comment Share on other sites More sharing options...
Solution shwetapandit Posted November 16, 2013 Author Solution Share Posted November 16, 2013 get solved Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.