<?PHP
@session_start();
$userId=$_SESSION['userId'];
if(!session_is_registered("userId"))
{
echo "<Script language=\"javascript\">window.location=\"index.php\"</script>";
}
if(session_is_registered("userId"))
{
$userId=$_SESSION["userId"];
}
?>
<?PHP
require_once('conn.php');
$status="";
if($_SERVER["REQUEST_METHOD"]=='POST')
{
$username=$_POST['username'];
$userpassword=$_POST['userpassword'];
$qury="select * from login where username='$username' and userpassword='$userpassword'";
echo($qury);
$res=mysql_query($qury) or die ("can not process the query".mysql_error());
$count=mysql_num_rows($res);
if($count>0){
while($row=mysql_fetch_array($res)){
$userId=$row['userId'];
$username=$row['username'];
}
session_start();
$_SESSION['userId']=$userId;
$_SESSION['username']=$username;
echo "<Script language=\"javascript\">window.location=\"APS.php\"</script>";
}
else {
echo('badluck');
}
}
?>
tahir_bsit
0
Newbie Poster
Recommended Answers
Jump to PostThats because of the first line of your code. The javascript redirection. Everytime you open the page, it will see if the session variable is set. Obviously, it will be empty. So it keeps redirecting :)
All 4 Replies
nav33n
472
Purple hazed!
Team Colleague
Featured Poster
tahir_bsit
0
Newbie Poster
nav33n
472
Purple hazed!
Team Colleague
Featured Poster
silviuks
0
Junior Poster in Training
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.