<?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');
}
}
?>

Recommended Answers

All 4 Replies

Thats 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 :)

<?php 
require_once('conn.php');
$form_Id=$_POST['form_Id'];
$qry="delete from adm_form where form_Id=$form_Id";
echo($qry);
$res=mysql_query($qry) or die ('query not processed');
echo('record deleted');
?>

why this code also give error.
Error = delete from adm_form where form_Id=query not processed

Instead of die ('query not processed'); give die(mysql_error()); and tell us what it prints.

For your second question:
you do not pass $form_Id to the query

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.