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();
?>
relative path issue on localhost
Moderator: General Moderators
-
steve_linn
- Forum Newbie
- Posts: 20
- Joined: Thu Jul 10, 2008 1:10 pm
-
WebbieDave
- Forum Contributor
- Posts: 213
- Joined: Sun Jul 15, 2007 7:07 am
Re: relative path issue on localhost
Instead of a relative URI, try an absolute one:
Code: Select all
header('Location: /wms/main.php');-
steve_linn
- Forum Newbie
- Posts: 20
- Joined: Thu Jul 10, 2008 1:10 pm
Re: relative path issue on localhost
that's the solution!