/    Sign up×
Community /Pin to ProfileBookmark

Form field filling

If for example we have a form with 5 fields;
someone fills them up and clicks on submit; once submitted to the action page the action page notices something wrong and redirects the user back to the same page … is there anyway that it can return to the page (without saving information on the database, or entering information as GET) but once returned all the fields are re-filled with what the user has filled?

Sorry for the bad explanation.

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@gersompieAug 20.2008 — I think the best thing you can do is just put the script in the same page as the form.

Then this is possible:
<i>
</i>print '&lt;input type="text" name="user_text" value="'.$_POST[user_text].'" /&gt;


When you don't want that you have to save the information in SESSION variables so the user doesn't see GET variables in the URL..
<i>
</i>session_start(); // &lt;= at the top of the page
$_SESSION[session_user_text] = $_POST[user_text];
header('Location: filename.php');


<i>
</i>session_start(); // &lt;= at the top of the page
print '&lt;input type="text" name="user_text" value="'.$_SESSION[session_user_text].'" /&gt;
Copy linkTweet thisAlerts:
@SyCoAug 20.2008 — I like the separate actions page as it gets rid of all those nasty resend info messages. You can post variables back to the original page using cURL if you have it on your server or store them in the session, redirect back to the original page and clear the session vars.
Copy linkTweet thisAlerts:
@gersompieAug 21.2008 — I keep the resend messages until nothing has gone wrong. Then i just redirect once more to the same page.
×

Success!

Help @XeroSiS spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...