Thanks for the quick response ..below is the code that sets the patchurl session and redirect the user to register or login.
<?php
session_start();
?>
<?php
echo '<script type="text/javascript">' . "\n";
if(isset($_SESSION["Email"])){
echo 'window.location="http://www.xxx";';
}
else{
$_SESSION['patchurl'] = "true";
echo 'window.location="http://yyy";';
}
echo '</script>';?>
If the user is not registered he provides all the information and submits the information and that runs the below php file
below is the code where i set the email session variable and not able to get the patchurl session variable..
<?phpsession_start();
?>
<html><head></head>
<body>
<?php
// Create connection
$con=mysql_connect("db","yyyy","xxxx");
// Check connection
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("yyyy", $con);
$Email = mysql_real_escape_string($_POST['Email']);
$pwd1 = mysql_real_escape_string($_POST['pwd1']);
$pwd2 = mysql_real_escape_string($_POST['pwd2']);
$Cname = mysql_real_escape_string($_POST['Cname']);
$ques1 = mysql_real_escape_string($_POST['ques1']);
$ques2 = mysql_real_escape_string($_POST['ques2']);
if(isset($Email)){
$result = mysql_query("SELECT * FROM customer WHERE Email = '$Email'");
$get_rows = mysql_affected_rows($con);
if($get_rows >=1){
//echo "user exists";
die();
}
}
//THIS IS WERE I AM SETTING THE EMAIL SESSION VARIABLE
$_SESSION["Email"] = $Email;
//inserting all the required value to register the customer
$sql = "INSERT INTO `customer` (`Email`,`pwd1`,`pwd2`,`Cname`,`ques1`,`ques2`,`Identity`)
VALUES
('$_POST[Email]', '$_POST[pwd1]', '$_POST[pwd2]', '$_POST[Cname]','$_POST[ques1]', '$_POST[ques2]','$numb')";
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
if(isset($_SESSION["Email"]))
{?>
// This is were the problem is after some troubleshooting i feel that once the session email is set this "patchurl session is doesn't seem to be live , i don't think i am getting in to the below if statement
<?php
if(isset($_SESSION["patchurl"])){
echo '<script type="text/javascript">' . "\n";
echo 'window.location="http://www.zzzz.com";';
echo '</script>';
}
else{?>
<?php
echo '<script type="text/javascript">' . "\n";
echo 'window.location="http://www.kkkk.com";';
echo '</script>';
?>
<?php
}
?>
</body>
</html>