Getting Undefined Variable: PHP_SELF
This application code that I downloaded from the site, but it shows up in the error log Getting variable Undefined: PHP_SELF on line 150, in index.php, now line 150
<form name=test action="<?php echo $PHP_SELF; ?>" method="GET">
This is the complete code of the form
<form name=test action="<?php echo $PHP_SELF; ?>" method="GET">
<table border=0 align=center>
<tbody>
<tr>
<td>
<input class="name" onclick="this.value=''" value="<?php echo $firstName ?>" name=p1>
</td>
<td style="background-image: url(images/heart.png); width: 133px; height: 119px; align: center;">
<div id=targetDiv align=center valign="top" style="font-size: 36px; margin-bottom: 10px;">
<?php
echo $result;
?>
</div>
</td>
<td>
<input class="name" onclick="this.value=''" value="<?php echo $secondName ?>" name=p2>
<br />
</td>
</tr>
</tbody>
</table>
+3
source to share
2 answers
It is assumed to be an index in a variable $_SERVER
:
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" ...>
Of course, if you haven't defined it:
$PHP_SELF = $_SERVER['PHP_SELF'];
Alternatively, you can also omit it as your intention is to submit the form on the current page:
<form action=""
+5
source to share
I think you are looking for a server variable:
<?php echo $_SERVER['PHP_SELF']; ?>
Take a look here: http://php.net/manual/en/reserved.variables.server.php
+2
source to share