I need to, in case of an unsuccessful attempt to submit the form, the entered values ​​are saved in the fields. I saw it doing so:

<form id="FeedbackForm" name="FeedbackForm" method="post" action="request.php"> <input type="text" id="name" name="name" value="<?php echo $_POST["name"]; ?>"/> <!-- продолжение формы --> </form> 

That is, we substitute the values ​​of the $_POST array in the fields, if any.

But for some reason, it does not work for me, that is, there is no substitution in the fields. The request.php script returns a page with a form (its work has already been debugged) when the sending is banned due to input errors.

What could be the reason?

  • var_dump($_POST); What does it show on the form receipt page? - Visman
  • Shows array (size=0) when sending is unsuccessful ... My script sends mail and is terminated via die() if at least one field is entered incorrectly. - Lateral Gleb
  • What does "unsuccessful sending" mean? If you entered the data in the form and sent it from the browser, then even the "wrong" data should go to the script and get into $_POST . - Visman
  • This means that the script found invalid data and completed its execution without sending an email. The sending script actually receives $_POST data, for some reason it still shows the array (size=0) when returning to the page with the form after the script is interrupted. - Lateral Gleb
  • Maybe die() destroys the $_POST array? - Lateral Gleb

1 answer 1

Because your request ( action="request.php" ) goes to another file, I see several ways:

  1. Javascript (as I understand it does not suit you);
  2. Perform processing in the same file from which the form is sent;
  3. Use cookies (but again, you can disable);
  4. Use session.
  • Even higher it was said that through include is possible, yes? - Lateral Gleb
  • Yes, you can connect the file where the processing takes place to the file where this form is located :) - Nikolay
  • Fine! Thanks for the perfect answer ~ _ ^ - Bokov Gleb