$ _SERVER ['PATH_INFO'] .. Defined index: PATH_INFO

I use the code to post as the header:

$fullurl=$_SERVER['PATH_INFO']; echo ' <form action="'. $fullurl .'" method="POST"> <table width="1000" border="1" cellpadding="10" id="navigationBar"> <tr> <td> <a href="/PoliticalForum/Registration.php">Register</a></td> <td> <a href="/PoliticalForum/controlPanel.php">Control Panel</a></td> <td> <a href="/PoliticalForum/checkEmail.php">Donate</a> </td> <td align="right">name:<input name="name" type="text" /></td> <td>password:<input name="pass" type="text" /> <input name="login" type="submit" value="Login" /> </td> </tr> </table> </form> '; 

I include the header in the request page files once. I want the fullurl variable to get the full URL of the page to which it was "required_once", and when I click the "Submit" button, I want it to be redirected to the page where the header is included. I added the url to the form action.

But I get the following:

 Undefined index: PATH_INFO 

I tried using them instead:

 explode('/', substr(parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH),1)); $_ENV['PATH_INFO']; 

But they did not work either: (

+1
source share
2 answers
  <form action="" method="POST"> 

what all

it also makes no sense to repeat the raw HTML file, use this code instead of your

 ?> <form action="" method="POST"> <table width="1000" border="1" cellpadding="10" id="navigationBar"> <tr> <td> <a href="/PoliticalForum/Registration.php">Register</a></td> <td> <a href="/PoliticalForum/controlPanel.php">Control Panel</a></td> <td> <a href="/PoliticalForum/checkEmail.php">Donate</a> </td> <td align="right">name:<input name="name" type="text" /></td> <td>password:<input name="pass" type="text" /> <input name="login" type="submit" value="Login" /> </td> </tr> </table> </form> 

+3
source

You can also try:

 <form action="<?=$_SERVER['PHP_SELF']?>" method="POST"> <input type="submit" name="form-submit" value="Submit" /> 

This will cause the form to be submitted to itself (current page). Use the variable in your form to detect submission or "regular page load." For instance.

 if (isset($_POST['form-submit'])){ //do stuff } 
+1
source

Source: https://habr.com/ru/post/1403537/


All Articles