1

I have a form that requires all information to be filled out and I have the script that checks to see if the fields are filled in, but I am unable to figure out how to get it to redirect back to the form with POST data to explain the error, is there such a way to do this????

I know it's possible to do this with GET data like so header("Location: index.php?e=1"); but I want to have the URL simply say:

https://foo.bar/index.php instead of https://foo.bar/index.php?e=1

2
  • I believe it is impossible to redirect with a POST request. The resulting request will always be a get request and any post data that was send to the first url will not be send to the second url. Commented Aug 17, 2014 at 6:53
  • The browser won't allow this because POST should be sent to the location the user is aware of. Forwarding POST data is seen as a sort of break in the post data 'chain of custody'. Commented Aug 17, 2014 at 6:56

1 Answer 1

2

In you HTML you could write code like this :

<input name="name" value="<? echo isset($_POST['name'])? $_POST['name']:"default_value";?>">

//Expecting you submission would be on same page where your have written your HTML content.
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.