Page 1 of 1

relative path issue on localhost

Posted: Thu Jul 10, 2008 1:15 pm
by steve_linn
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();
?>

Re: relative path issue on localhost

Posted: Thu Jul 10, 2008 1:22 pm
by WebbieDave
Instead of a relative URI, try an absolute one:

Code: Select all

header('Location: /wms/main.php');

Re: relative path issue on localhost

Posted: Thu Jul 10, 2008 2:05 pm
by steve_linn
that's the solution!