Jump to content

What is creating a second trailing slash???


waznik

Recommended Posts

Hi, i'm a bit of a newbe with little knowledge but keen to learn!

 

I recently had a login script developed for me (unfortunately the developer is nolonger available)...

 

After login, the user would either be redirected to their home page or denied access due to incorrect credentials!

 

Unfortunately, the login script seems to add a second trailing slash after the main domain (eg: if login successful www.domain.com/login.php redirects to www.domain.php//users/joebloggs/home.php. If unsuccessful www.domain.com/login.php redirects to www.domain.php//login.php?errmsg=2). That second slash then remains whilst navigating throughout the site unless manually removed in address bar!

 

Until recently this did not seem to cause a problem as the site worked regardless, since moving the site to a supposedly better hosting company this little glitch now causes problems with other php scripts - they work fine if the second slash is manually removed from the address bar.

 

QUESTION: Can anyone see how I can remove this second trailing slash by looking at the code below... The login.php page simply calls for login_script.php & iprocesslogin.php (detailed below).

 

login_script.php Start

<?php

 

//get user name and password from form

$uname = $HTTP_POST_VARS['uname'];

$pword = $HTTP_POST_VARS['pword'];

 

//set logged in variable to False

$loggedIn = 1;

 

//get users list

$users = file("cgi-bin/user_list.txt");

 

//loop through users

while(list($k, $v) = each($users))

{

 

//get users details

$tempuser = explode("~", trim($v));

 

//check username

if ($tempuser[0] == $uname)

 

{

//now check password

if ($tempuser[1] == $pword){

 

//set loggedIn to be true, session variable fullName and set cookie

$loggedIn = 0;

 

//create cookie

setcookie ("uname", $uname, time()+5400);

$relative_url = "users/".$uname."/home.php";

 

}else{

 

$relative_url = "login.php?errmsg=2";

 

}

 

break;

 

}else{

 

$relative_url = "login.php?errmsg=1";

 

}

 

}

 

//redirect to the correct location

// next line commented out by mce due to bug in IIS.  You could put it back live but you must also comment out the line further down

// header("Location: http://".$HTTP_SERVER_VARS['HTTP_HOST'].dirname($HTTP_SERVER_VARS['PHP_SELF'])."/".$relative_url);

 

?>

 

<!-- next line added by mce due to bug in IIS.  You could comment it out but then you must un-comment line further up -->

<meta HTTP-EQUIV="refresh" content=0;url=<?php echo "http://".$HTTP_SERVER_VARS['HTTP_HOST'].dirname($HTTP_SERVER_VARS['PHP_SELF'])."/".$relative_url; ?>>

 

login_script.php End

 

iprocesslogin.php Start

<?php

 

// if "logoff" is in the URL then set the cookie to expire in 1 second

if (!empty($HTTP_GET_VARS["logoff"])){

$errmsg = 4;

setcookie ("uname", '', time()+1);

}

 

//check for errmsg

if (empty($HTTP_GET_VARS["errmsg"])){

$errmsg = 0;

}else{

$errmsg = $HTTP_GET_VARS["errmsg"];

}

 

switch ($errmsg) {

case 0:

$errmsg = "";

break;

case 1:

$errmsg = "<br>Incorrect username or password, please re-enter carefully...<br><br>If you have

recently applied for an account with us, your account may not yet be active...

If you have any concerns please call us on 01442 404085.<br> ";

break;

case 2:

$errmsg = "<br>Incorrect username or password, please re-enter carefully...<br><br>If you have

recently applied for an account with us, your account may not yet be active...

If you have any concerns please call us on 01442 404085.<br> ";

break;

case 3:

$errmsg = "<br>ERROR : You do not have access to that page or it may have expired...<br><br>

Please log in above.<br>

If you have any concerns please call us on 01442 404085.<br> ";

break;

case 4:

$errmsg = "You have logged off.";

break;

}

 

//check for user cookie

if (empty($_COOKIE["uname"])){

$cookieName = '';

}else{

$cookieName = $_COOKIE["uname"];

}

 

?>

 

iprocesslogin.php End

 

Thanks in advance...

 

Link to comment
https://forums.phpfreaks.com/topic/98423-what-is-creating-a-second-trailing-slash/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.