Alright, here is my problem i’m trying to solve. I have an index page built with a bunch of php includes to other files on the server. For example, a file to build my menu’ing, etc.
Of those files, i am working with a include that builds a table on the page with a delete button on each row, so that the data can be removed by the user if needed. With that being said, the page that builds the table is using this form definition:
<form name=somename id=someid method=post action=<?php $PHP_SELF?>
Well whats happening is, when the delete is executed the form tries to post to itself and it throws an error into the address bar of:
Notice: Undefined variable: PHP_SELF in C:\xampp\htdocs \web\somefile.php on line 39
Line 39 is the form attribute.
=================================
The setup of the index page that contains this is like so:
<div id="container">
<div id="left">
<p>Welcome <?php echo $_SESSION['USERFIRSTNAME']?> <?php echo $_SESSION['USERLASTNAME']?></p>
</div>
<div id="right">
<?php
//navigation menu
include('menu.php');
?>
</div> <!-- menu div -->
<div class="clear"></div>
</div> <!-- container div -->
<div id="userlist">
<?php
//build user access links
//include('userlist.php');
?>
</div><!-- user list div -->
<div id="dbview">
<?php
include('dbview.php');
?>
</div>
the dbview.php builds the table i was speaking about above.
I’m trying to figure out how i can execute the delete (which simply updates a db row) while it refreshes back to the index page. The current code which i’m using to handle the post doesn’t seem to be working:
if (($someresult)&& ($anotherresult))
{
echo'<font color="#FF0000">You have successfully removed item </font>';
header('Location: index.php');
exit;
}
else
{
echo'<font color="#FF0000">Error while Removing</font>';
}
all the issue seems to be with the $PHP_SELF part, but i need some assistance. I’m sorry for the drawn out post. Hopefully it makes sense. If more code needs to be posted i can do that as well. Thanks again!
The data you want is actually held in
$_SERVER['PHP_SELF'].If you are expecting a variable called
$PHP_SELFto be defined, I suspect you are used to working with a server where register_globals was enabled, which is rarely the case any more. If this is the case, you should also be aware the variables passed through$_GETand$_POSTwill also not be defined.