hye ,
My current Directory structure is like
- Admin (index.php, country.php)
- Classes(connection.php,login.php,country.php)
- header.php
- footer.php
- index.php
- includes(header.php,footer.php)
my problem is that on webserver when i am in /admin/country.php and add a country using form post method and action set to /classes/country.php my header statement "Header("Location: ../Admin/country.php")" is working ok but when i am on my index page in root directory and try to login with form action "classes/login.php" and on successful login i use header("Location: ../Admin/index.php") it never redirects but everything works fine my local server, i don't know whats the problem over here, Any help would be really appreciated,
I have searched this forum and others and tried to use the techniques they have told but nothing is working
my index page index.php
my Admin Section Admin/Country.php
my login.php script is below
ob_start();
include_once("classes/connection.php");
?>
class login
{
public static function validateLogin($userName,$password)
{
if(isset($userName) && isset($password))
{
$connection = dbconnection::getConnection();
$query = "Select * from tbllogin Where loginID ='" . $userName .
"' and password = '" . $password . "'";
$result = mysql_query($query);
$rowsAffected = mysql_affected_rows();
if($rowsAffected==0)
{
//header("Location: ../index.php/");
//exit();
return false;
}
else
{
while($row = mysql_fetch_array($result))
{
//working
$role = $row["role"];
if($role == "Admin")
{
//header('Location: ../Admin/index.php');
//exit();
return true;
}
else
{
//echo "hello";
//header("Location: ../index.php/");
//exit();
return false;
}
//return $result;
//header("Location: ../index.php");
}
}
}
else
{
//header("Location: ../index.php/");
return false;
}
}
}
?>
if(isset($_POST["btnSumbit"]))
{
$isValid = login::validateLogin($_POST["userID"],$_POST["password"]);
if(isset($isValid))
{
if($isValid ==true)
{
$host = $_SERVER['HTTP_HOST'];
$uri = rtrim(dirname($_SERVER['PHP_SELF']), '/\\');
$extra = 'Admin/index.php';
header("Location: http://$host$uri/$extra");
exit();
}
}
}
ob_end_flush();
?>
No comments:
Post a Comment