relative path issue on localhost
Posted: Thu Jul 10, 2008 1:15 pm
Hello. I'm very new to PHP programming: looking for some assistance
I have a script that goes to the wrong page on the localhost - it uses header (LOCATION: )
here is the url that the code goes to:
http://localhost/wms/library/main.php
here is where I want the code to go:
http://localhost/wms/main.php
here is the code:
<?php
ob_start();
include("db_connect.php");
// Check to See if user is authorized
$result = mysql_query("SELECT * FROM users WHERE username='" . $_GET[$Username] . "' AND password='" . $_GET[$Password] . "'");
$row = mysql_fetch_row($result);
if ($row[1] == $_GET [$Username]){
if ($row[2] == $_GET [$Password]){
//Set Cookie for Login
if (isset($_COOKIE["username"])){
setcookie("username",$_GET['Username'],time()+1209600,"/","localhost",0);
setcookie("password",$_GET['Password'],time()+1209600,"/","localhost",0);
} else{
setcookie("username",$_GET['Username'],time()+1209600,"/","localhost",0);
setcookie("password",$_GET['Password'],time()+1209600,"/","localhost",0);
}
header("Location: main.php");
exit;
}
else{
header("Location:index.php");
exit;
}
}
else{
header("Location:index.php");
exit;
}
mysql_free_result($result);
mysql_close($dbwms);
ob_end_flush();
?>
I have a script that goes to the wrong page on the localhost - it uses header (LOCATION: )
here is the url that the code goes to:
http://localhost/wms/library/main.php
here is where I want the code to go:
http://localhost/wms/main.php
here is the code:
<?php
ob_start();
include("db_connect.php");
// Check to See if user is authorized
$result = mysql_query("SELECT * FROM users WHERE username='" . $_GET[$Username] . "' AND password='" . $_GET[$Password] . "'");
$row = mysql_fetch_row($result);
if ($row[1] == $_GET [$Username]){
if ($row[2] == $_GET [$Password]){
//Set Cookie for Login
if (isset($_COOKIE["username"])){
setcookie("username",$_GET['Username'],time()+1209600,"/","localhost",0);
setcookie("password",$_GET['Password'],time()+1209600,"/","localhost",0);
} else{
setcookie("username",$_GET['Username'],time()+1209600,"/","localhost",0);
setcookie("password",$_GET['Password'],time()+1209600,"/","localhost",0);
}
header("Location: main.php");
exit;
}
else{
header("Location:index.php");
exit;
}
}
else{
header("Location:index.php");
exit;
}
mysql_free_result($result);
mysql_close($dbwms);
ob_end_flush();
?>