Page 1 of 1

What is PHP_Self ? How do I properly configure it?

Posted: Tue Jan 04, 2005 6:51 pm
by rmilone
I installed a PHP login script. After registering, an email is sent, with a link. It brings you back to the login page. The link looks like this ( not actual site):

http://www.mywebpage.com//login.php?ide ... d6809cadc1

When you are back at the login page, enter the password, hit submit, you get a "Page can not be found" error. Its trying to go to http://login.php/

When I look at the source via the browser, you see this

<h2 class="style4">Please login to access the Members Only sections of mywebpage.com</h2>
<form name="form1" method="post" action="//login.php">

When I look at the source via Dreamweaver, I see this:

<p>Enter here your new password, (login: <b><?php echo $act_password->user; ?></b>).</p>
<form name="form1" method="post" action="<?php echo $PHP_SELF; ?>">

So, it seems that PHP_SELF is adding the //. Should it just point to login.php, or the full path? How can I remedy this?

Thanks,
Rob

Posted: Tue Jan 04, 2005 7:11 pm
by AVATAr
it seems that the link the script sends have the //, try hacking the link its sending so it only put one /

Posted: Tue Jan 04, 2005 7:36 pm
by feyd
uh... $PHP_SELF doesn't exist unless register_globals is on. Your looking for $_SERVER['PHP_SELF'] or $_SERVER['SCRIPT_NAME']

Posted: Tue Jan 04, 2005 7:51 pm
by rmilone
So how do I edit the script to leave out the extra / ?

Posted: Tue Jan 04, 2005 8:18 pm
by John Cartwright
open the file in notepad..

change

Code: Select all

action="//login.php">
to

Code: Select all

action="login.php">
not quite sure what you meant..

Posted: Wed Jan 05, 2005 1:04 am
by rmilone
Sorry, this is my first web page, and I just started playing around with PHP. Here was the problem, between the message line, there was a "/". Once I took that out ( its now just ""), it worked fine.

Code: Select all

$msg[29] = "Hallo,\r\n\r\nto activate your request click the following link:\r\nhttp://".$HTTP_HOST.dirname($PHP_SELF)."".$this->login_page."?ident=".$this->id."&activate=".md5($this->user_pw);