Jump to content

Problem with session


ra_ie_darkness

Recommended Posts

I'm using xampp and am trying to create a login session...these are the my php files

login.php

<form action='login1.php' method='post'>
Email: <input type='text' name='id'></br>
Pass : <input type='password' name='pass'></br>
<input type='submit' name='login' value='login'>

login1.php

<?php
$id=$_POST['id'];
$pass=$_POST['pass'];

$conn=mysql_connect("localhost","root","");
if (!$conn)
{
die('Could not connect: ' . mysql_error());
}


$e=mysql_select_db('test', $conn);
if(!$e)
{
die(''.mysql_error());
}
else
{
echo 'database selected successfully';
}

$sql=mysql_query("Select email,password from login where email='$id' AND password='$pass'");
$count=mysql_num_rows($sql);
if($count==1) 
{ 
    session_start();
    
    echo "</br>Login Successful</br>";
echo "Please wait 5 seconds ";
/* redirct to the specified page */	
header("refresh:5;url=empty.php");
}
else
{

echo "please try to login again</br>";
echo "you will be redirected to the login page in 5 seconds";
     /* redirct to the specified page */
header("refresh:5;url=login.php");
}
mysql_close();
?>

empty.php

<?php
session_start();

$logi=$_SESSION['id'];
echo 'welcome '.$logi;



?>

 

empty.php is supposed to display the email id from login.php

I checked it about an hour ago and it was working fine but now it gives me an error

Undefined index: id in C:\xampp\htdocs\littleprogress\empty.php on line 4

I didn't change anything after checking it. only cleared the history and cookies of my firefox browser

what could be the problem

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.