Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Undefined Variable PHP_SELF

I am developing a backend with php here.

I am having problem with such error like this:

Undefined variable : PHP_SELF

on my htdocs directory.

I'm developing with php 5.4.4 , and if you want to look at the source code here it is:

http://pastebin.com/xr2PxbNG

like image 592
adadeh Avatar asked Oct 03 '12 14:10

adadeh


3 Answers

Do not use any of the suggested versions of PHP_SELF. It is a security nightmare, opening up your PHP to a multitude of possible injection attacks.

What are you trying to achieve? Generate the URL for a form sending to itself? Use action="" for that - it is a valid approach and will always use the URL for sending the form as for loading.

If you must know the requested script, use $_SERVER['SCRIPT_NAME'] instead.

like image 139
Sven Avatar answered Nov 03 '22 23:11

Sven


You are using $PHP_SELF it should be

echo $_SERVER['PHP_SELF'] ;

Or

$PHP_SELF = &$_SERVER['PHP_SELF'];
echo $PHP_SELF ;

You can also have

define("PHP_SELF",$_SERVER['PHP_SELF']); 
echo PHP_SELF ;
like image 31
Baba Avatar answered Nov 03 '22 22:11

Baba


Are you trying to access $_SERVER['PHP_SELF'] ?

like image 3
Lkrups Avatar answered Nov 03 '22 22:11

Lkrups