[SOLVED] What is PHP_Self ? How do I properly configure it?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
rmilone
Forum Newbie
Posts: 3
Joined: Tue Jan 04, 2005 6:23 pm

What is PHP_Self ? How do I properly configure it?

Post 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
User avatar
AVATAr
Forum Regular
Posts: 524
Joined: Tue Jul 16, 2002 4:19 pm
Location: Uruguay -- Montevideo
Contact:

Post by AVATAr »

it seems that the link the script sends have the //, try hacking the link its sending so it only put one /
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

uh... $PHP_SELF doesn't exist unless register_globals is on. Your looking for $_SERVER['PHP_SELF'] or $_SERVER['SCRIPT_NAME']
rmilone
Forum Newbie
Posts: 3
Joined: Tue Jan 04, 2005 6:23 pm

Post by rmilone »

So how do I edit the script to leave out the extra / ?
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post 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..
rmilone
Forum Newbie
Posts: 3
Joined: Tue Jan 04, 2005 6:23 pm

Post 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);
Post Reply