user3915050
user3915050

Reputation:

PHP POST data in header() function

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

Upvotes: 1

Views: 75

Answers (1)

Vivek Pratap Singh
Vivek Pratap Singh

Reputation: 9974

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.

Upvotes: 2

Related Questions