473,508 Members | 2,247 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

action="<?=$PHP_SELF?>">

Can not determine how "<?=PHP_SELF?>" is supposed to work.

The below is the line of code.
<!-- <form name="search" method="post" action="<?=$PHP_SELF?>"-->

When the above statement is run the following is the result.

You don't have permission to access /dev/forms/forms_testing/< on this
server.

Jun 6 '07 #1
18 10707
zoilus wrote:
Can not determine how "<?=PHP_SELF?>" is supposed to work.

The below is the line of code.
<!-- <form name="search" method="post" action="<?=$PHP_SELF?>"-->

When the above statement is run the following is the result.

You don't have permission to access /dev/forms/forms_testing/< on this
server.
Hi,

Why make things complicated?
Why don't you just fill in the name of the script you want?
Don't you know how your script is named?

I never understood why people want to use PHP_SELF.
:-/

Regards,
Erwin Moller
Jun 6 '07 #2
As I often do, I try learning from other peoples work. This script was
on a site and I thought it interesting. Trying to dig out interesting
tidbits. I had already put the 'search.php' in it's place but was
curious as to what and why $PHP_SELF was "Trying to be used" because is
was not working. This made it more interesting. I looked up what I think
it was to do but still can not figure out why it is not working.

Anyway.....
Erwin Moller wrote:
zoilus wrote:

>>Can not determine how "<?=PHP_SELF?>" is supposed to work.

The below is the line of code.
<!-- <form name="search" method="post" action="<?=$PHP_SELF?>"-->

When the above statement is run the following is the result.

You don't have permission to access /dev/forms/forms_testing/< on this
server.


Hi,

Why make things complicated?
Why don't you just fill in the name of the script you want?
Don't you know how your script is named?

I never understood why people want to use PHP_SELF.
:-/

Regards,
Erwin Moller

Jun 6 '07 #3
Erwin Moller wrote:
I never understood why people want to use PHP_SELF.
Portability.

Cheers,
--
----------------------------------
Iván Sánchez Ortega -ivansanchez-algarroba-escomposlinux-punto-org-

http://acm.asoc.fi.upm.es/~mr/
Proudly running Debian Linux with 2.6.20-1-amd64 kernel, KDE 3.5.7, and PHP
5.2.2-2 generating this signature.
Uptime: 18:17:59 up 6 days, 20 min, 3 users, load average: 1.52, 2.26,
2.15

Jun 6 '07 #4
zoilus wrote:
As I often do, I try learning from other peoples work. This script was
on a site and I thought it interesting. Trying to dig out interesting
tidbits. I had already put the 'search.php' in it's place but was
curious as to what and why $PHP_SELF was "Trying to be used" because is
was not working. This made it more interesting. I looked up what I think
it was to do but still can not figure out why it is not working.

Anyway.....

Hi Zoilus,

The one and foremost way to debug form-postings (in my humble opinion of
course) is dumping the posting in PHP.

for example: You post a form with method="post" to search.php

then in search.php start with this:

<?php
// dump the post
echo "<pre>";
print_r($_POST);
echo "</pre>";
exit;
?>

I must have typed the sequence of lines a zillion times by now. ;-)

You can do the same with $_GET (for forms that use method="get").
or for cookies: $_COOKIE
or actually for any array you might want to inspect.

Do not forget the <pre>..</prebecause print_r() is nicely formatted only
if you use pre.

Hope that helps.
Regards,
Erwin Moller
>

Erwin Moller wrote:
>zoilus wrote:

>>>Can not determine how "<?=PHP_SELF?>" is supposed to work.

The below is the line of code.
<!-- <form name="search" method="post" action="<?=$PHP_SELF?>"-->

When the above statement is run the following is the result.

You don't have permission to access /dev/forms/forms_testing/< on this
server.


Hi,

Why make things complicated?
Why don't you just fill in the name of the script you want?
Don't you know how your script is named?

I never understood why people want to use PHP_SELF.
:-/

Regards,
Erwin Moller

Jun 6 '07 #5
Iván Sánchez Ortega wrote:
Erwin Moller wrote:
>I never understood why people want to use PHP_SELF.

Portability.
Right, I see your point.
Comes in handy when using general form-generating routines and the like. ;-)

Regards,
Erwin Moller
>
Cheers,
Jun 6 '07 #6
On 6 Jun, 16:56, zoilus <zol...@someplace.orgwrote:
Can not determine how "<?=PHP_SELF?>" is supposed to work.

The below is the line of code.
<!-- <form name="search" method="post" action="<?=$PHP_SELF?>"-->

When the above statement is run the following is the result.

You don't have permission to access /dev/forms/forms_testing/< on this
server.
Erm... why don't you just view the HTML source to see what's in the
$PHP_SELF variable?

Jun 6 '07 #7
On Jun 6, 10:56 am, zoilus <zol...@someplace.orgwrote:
Can not determine how "<?=PHP_SELF?>" is supposed to work.

The below is the line of code.
<!-- <form name="search" method="post" action="<?=$PHP_SELF?>"-->

When the above statement is run the following is the result.

You don't have permission to access /dev/forms/forms_testing/< on this
server.
not sure your version of php or it's config, but try using
$_SERVER['PHP_SELF']; or set a global variable to $PHP_SELF =
$_SERVER['PHP_SELF']; then reference throughout your app whenever
necessary.

Also, educate yourself a bit more on this subject at http://us.php.net/reserved.variables

hth,

-----------
Gene Kelley
LAMP Web Application Developer
BizFlowDesigns.com
St. Louis, Missouri, USA

Jun 6 '07 #8
zoilus wrote:
>
Can not determine how "<?=PHP_SELF?>" is supposed to work.

The below is the line of code.
<!-- <form name="search" method="post" action="<?=$PHP_SELF?>"-->

When the above statement is run the following is the result.

You don't have permission to access /dev/forms/forms_testing/< on this
server.
The <?=PHP_SELF?syntax requires short tags and register globals to be
on. Both are off on most default installations nowadays. Try this and
see if that works:

<?php echo $_SERVER['PHP_SELF']; ?>
Jun 6 '07 #9
Erwin Moller wrote:
Iván Sánchez Ortega wrote:
>Erwin Moller wrote:
>>I never understood why people want to use PHP_SELF.
Portability.

Right, I see your point.
Comes in handy when using general form-generating routines and the like. ;-)
I would advise:

// prevent some wiseass XSS insertion
$sanitized=htmlentities($_SERVER['PHP_SELF']);

<form action="<?php echo $sanitized; ?>" method="post">
--
Take care,

Jonathan
-------------------
LITTLE WORKS STUDIO
http://www.LittleWorksStudio.com
Jun 6 '07 #10
Ok, if one of you fine folks would like to explain this one. I do not
understand.

Erwin Moller wrote:
Iván Sánchez Ortega wrote:

>>Erwin Moller wrote:

>>>I never understood why people want to use PHP_SELF.

Portability.


Right, I see your point.
Comes in handy when using general form-generating routines and the like. ;-)

Regards,
Erwin Moller

>>Cheers,

Jun 6 '07 #11
Here ya go.

<h2>Search</h2>
<form name="search" method="post" action="<?=$PHP_SELF?>">
Seach for: <input type="text" name="find" /in
<Select NAME="field">
<Option VALUE="fname">First Name</option>
<Option VALUE="lname">Last Name</option>
<Option VALUE="info">Profile</option>
</Select>
<input type="hidden" name="searching" value="yes" />
<input type="submit" name="search" value="Search" />
</form>

gbbulldog wrote:
On 6 Jun, 16:56, zoilus <zol...@someplace.orgwrote:
>>Can not determine how "<?=PHP_SELF?>" is supposed to work.

The below is the line of code.
<!-- <form name="search" method="post" action="<?=$PHP_SELF?>"-->

When the above statement is run the following is the result.

You don't have permission to access /dev/forms/forms_testing/< on this
server.


Erm... why don't you just view the HTML source to see what's in the
$PHP_SELF variable?
Jun 6 '07 #12
I had been trying this one and a few others without success, until I
used this

// $PHP_SELF=$_SERVER['PHP_SELF']; //r&d
// print "$PHP_SELF"; //r&d

The above worked while others just blanked my php output.


Anonymous wrote:
zoilus wrote:
>>Can not determine how "<?=PHP_SELF?>" is supposed to work.

The below is the line of code.
<!-- <form name="search" method="post" action="<?=$PHP_SELF?>"-->

When the above statement is run the following is the result.

You don't have permission to access /dev/forms/forms_testing/< on this
server.


The <?=PHP_SELF?syntax requires short tags and register globals to be
on. Both are off on most default installations nowadays. Try this and
see if that works:

<?php echo $_SERVER['PHP_SELF']; ?>
Jun 6 '07 #13
Thanks, good suggestion. I will.

Jonathan N. Little wrote:
Erwin Moller wrote:
>Iván Sánchez Ortega wrote:
>>Erwin Moller wrote:

I never understood why people want to use PHP_SELF.

Portability.


Right, I see your point.
Comes in handy when using general form-generating routines and the
like. ;-)


I would advise:

// prevent some wiseass XSS insertion
$sanitized=htmlentities($_SERVER['PHP_SELF']);

<form action="<?php echo $sanitized; ?>" method="post">

Jun 6 '07 #14
Rik
On Thu, 07 Jun 2007 00:03:09 +0200, zoilus <zo****@someplace.orgwrote:
I had been trying this one and a few others without success, until I
used this

// $PHP_SELF=$_SERVER['PHP_SELF']; //r&d
// print "$PHP_SELF"; //r&d

The above worked while others just blanked my php output.
Some pointers:

- Never ever use the <?=$varname ?syntax. (Which assumes both shorttags
and register_globals set to On, both of which are a Bad Idea)

- Do not expect any magic variable to exist except the ones listed on
http://www.php.net/manual/en/languag...predefined.php (well,
including $this in classes etc.)

Also, putting double quotes around a single variable to echo, print, or do
anything else with it is just plain silly. All it does is it casts it toa
string, which is already assumed by echo/print constructs. If you really
need to cast it to a string, using strval() (only for scalars) or
(string)$varname is preferred. See
http://www.php.net/manual/en/languag...e-juggling.php for more
details on this.
Short answer:
<?php echo $_SERVER['PHP_SELF']; ?works almost all the time, depending
on what webserver you use (as it isn't provided by PHP itself, the server
tells PHP what it should be).
--
Rik Wasmus
Jun 6 '07 #15
Uneducated perhaps, but

3 a : weak in intellect : FOOLISH b : exhibiting or indicative of a lack
of common sense or sound judgment <a very silly mistake>

Ouch.
Rik wrote:
On Thu, 07 Jun 2007 00:03:09 +0200, zoilus <zo****@someplace.orgwrote:
>I had been trying this one and a few others without success, until I
used this

// $PHP_SELF=$_SERVER['PHP_SELF']; //r&d
// print "$PHP_SELF"; //r&d

The above worked while others just blanked my php output.


Some pointers:

- Never ever use the <?=$varname ?syntax. (Which assumes both
shorttags and register_globals set to On, both of which are a Bad Idea)

- Do not expect any magic variable to exist except the ones listed on
http://www.php.net/manual/en/languag...predefined.php (well,
including $this in classes etc.)

Also, putting double quotes around a single variable to echo, print, or
do anything else with it is just plain silly. All it does is it casts
it to a string, which is already assumed by echo/print constructs. If
you really need to cast it to a string, using strval() (only for
scalars) or (string)$varname is preferred. See
http://www.php.net/manual/en/languag...e-juggling.php for more
details on this.
Short answer:
<?php echo $_SERVER['PHP_SELF']; ?works almost all the time,
depending on what webserver you use (as it isn't provided by PHP
itself, the server tells PHP what it should be).
Jun 6 '07 #16
Uneducated perhaps, but

3 a : weak in intellect : FOOLISH b : exhibiting or indicative of a lack
of common sense or sound judgment <a very silly mistake>

Ouch. ;)
Rik wrote:
On Thu, 07 Jun 2007 00:03:09 +0200, zoilus <zo****@someplace.orgwrote:
>I had been trying this one and a few others without success, until I
used this

// $PHP_SELF=$_SERVER['PHP_SELF']; //r&d
// print "$PHP_SELF"; //r&d

The above worked while others just blanked my php output.


Some pointers:

- Never ever use the <?=$varname ?syntax. (Which assumes both
shorttags and register_globals set to On, both of which are a Bad Idea)

- Do not expect any magic variable to exist except the ones listed on
http://www.php.net/manual/en/languag...predefined.php (well,
including $this in classes etc.)

Also, putting double quotes around a single variable to echo, print, or
do anything else with it is just plain silly. All it does is it casts
it to a string, which is already assumed by echo/print constructs. If
you really need to cast it to a string, using strval() (only for
scalars) or (string)$varname is preferred. See
http://www.php.net/manual/en/languag...e-juggling.php for more
details on this.
Short answer:
<?php echo $_SERVER['PHP_SELF']; ?works almost all the time,
depending on what webserver you use (as it isn't provided by PHP
itself, the server tells PHP what it should be).
Jun 6 '07 #17
On Jun 6, 12:45 pm, gbbulldog <gbbull...@googlemail.comwrote:
On 6 Jun, 16:56, zoilus <zol...@someplace.orgwrote:
Can not determine how "<?=PHP_SELF?>" is supposed to work.
The below is the line of code.
<!-- <form name="search" method="post" action="<?=$PHP_SELF?>"-->
When the above statement is run the following is the result.
You don't have permission to access /dev/forms/forms_testing/< on this
server.

Erm... why don't you just view the HTML source to see what's in the
$PHP_SELF variable?
How about checking register globals for the first thing. If you have
it turned off, $PHP_SEKF is a junk variable with no meaning. Use
$_SERVER['PHP_SELF'] to be safe from register globals nightmares.

Spaghetti code starts with register_globals.

~A!

Jun 7 '07 #18
zoilus wrote:
Ok, if one of you fine folks would like to explain this one. I do not
understand.
Hi Zoilus,

First a housekeeping remark: Please do not toppost.
Try to insert your question/comments under the part where they belong.
Look at this old joke:

Answer: Because it destroys the natural order of the conversation.
Question: Why is that?
Answer: Topposting
Question: What is the most annoying thing on usenet?

;-)

About the PHP_SELF usage: I told you not to use it because you can just fill
in the name of the script you want to receive your form.
I also said I didn't see a point in using PHP_SELF.
Then Ivan said there is a good point: portability.
What he ment is that you can write code that you can use in other scripts
too, be it in classes or in a functionlib.
If you do not know WHAT the name of your own script is, you can use PHP_SELF
to fetch that for you.
If you cannot follow, do not mind. It only matters when you want to write a
functionlib or a few classes that you use to recycle some logic.
I would advise you not to use PHP_SELF for now. Maybe later when you are
more confortable with postings and forms.

The main point is that the action-tag in the form should hold a scriptname
so the browser knows where to send the info.

Hope that clarifies it a bit.

Regards,
Erwin Moller
>
Erwin Moller wrote:
>Iván Sánchez Ortega wrote:

>>>Erwin Moller wrote:
I never understood why people want to use PHP_SELF.

Portability.


Right, I see your point.
Comes in handy when using general form-generating routines and the like.
;-)

Regards,
Erwin Moller

>>>Cheers,

Jun 7 '07 #19

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
6028
by: Ankur Gupta | last post by:
How can I retrieve all the page name with arguments passed to itself? Using Php_Self tag with the following URL: ...
4
10179
by: Murali | last post by:
Hi, I have a php file, where i am using an include from a URL detail.php: $html = ""; $contentFile = "http://www.mysite.com/link.php"; if ( $contentFile ) { $fileBuffer =...
2
1891
by: KC Wong | last post by:
I am making an In-Site Search for a website, it is a PHP page where user can enter the keyword(s), and then the page will read through all other html/php pages to find that keyword(s). My problem...
0
1292
by: Anthony Hart-Jones | last post by:
1) Windows ME seems incapable of applying passwords to usernames. On my webspace, I can only log into the SQL database if I include the password. On my WinME PC, only if I do NOT give a password....
2
2096
by: pm1ccc | last post by:
Hi, I have written following code and not getting back values in the same form ( i have used phpself) <?php $Fname = $_POST; $Lname = $_POST; $gender = $_POST; $food = $_POST; $quote =...
5
12521
by: Jerim79 | last post by:
My boss has saddled me with this task, so I don't know all the specifics. What I do know, is that I am looking for something similar to this: <form action="<? echo $PHPSELF ?>" method="POST"> ...
0
7231
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7336
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7504
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5640
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5059
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4720
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
1568
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
773
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
432
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.