/    Sign up×
Community /Pin to ProfileBookmark

hey everyone, i don’t mean to nag but if anyone can tell me a good way to to create a subscription style site that uses 6 different forms/form pages. all i want to do is display one at a time and when….
Part 1 is submitted, it goes through validation, if it doesn’t pass, Part 1 is redisplayed, if it does
Part 2 is displayed……..and so on and so forth

I have tried this using a switch, if…elseif using include(), include_once(), require() and i just cannot get it right, either the validation works incorrectly or the next page loads wrong and so on. if anyone can point me somewhere it would be wonderful
thanks in advance
nick

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@NogDogJan 12.2007 — I'd use sessions to keep track of all the data that's been entered, allowing you to pre-populate forms if validation requires you to go back.
[code=php]
<?php
session_start();
?>
...
<input type="text" name="example" value="<?php
if(isset($_SESSION['example']))
{
echo htmlspecialchars($_SESSION['example'], ENT_QUOTES);
}
?>">
[/code]

Then when you process the form:
[code=php]
<?php
session_start();
foreach($_POST as $key => $val)
{
$_SESSION[$key] = (get_magic_quotes_gpc()) ? stripslashes($val) : $val;
}
[/code]

Note that this requires that all the form elements across all the pages have unique names (or at least all those whose values need to be kept track of).
×

Success!

Help @NickG21 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 5.19,
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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

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

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...