user3384012
user3384012

Reputation: 3

POST value becomes null after form is submitted

I have a a field with name username. I display the data on the second page using $_POST['username']. Below the displayed username is another form. When I submit that form, the page is refreshed and result is displayed on the same page. But what happens on the displayed username is that becomes null.

Upvotes: 0

Views: 1063

Answers (1)

Damon
Damon

Reputation: 4484

Because $_POST['username'] is nolonger in the post data. If you want to pass it along, create a hidden input on the second page with a name of "username" then set it's value to $_POST['username']

<input type="hidden" name="username" value="<?php echo $_POST['username'];?>" />

Now when you submit your page, the "username" post variable will be available again.

Upvotes: 1

Related Questions