I am working on the registration page for my game. I am using smarty to create the different pages that will be displayed throughout the game. I would like to create script say "register.php" that redirects to itself, and depending on weither this is the first time the user is viewing the form or submitting it it does something different. So for example the first time, the registration form is shown and then when the form is submitted the same page submits the registration info to the mysql server. This is the way the Wordpress script handles logins and registrations and i would like to mimic it. Any assistance would be greatly appreciated.
Sincerely,
Aleeious
If Form Was Submitted
Re: If Form Was Submitted
There are 2 ways going about it.
firstly, you could use 2 templates.
secondly, you could handle it inside a single template.
firstly, you could use 2 templates.
Code: Select all
if(isset($_POST['submit']))
{
$page = "registered";
}
else
{
$page = "register";
}
$smarty->display($page . ".tpl");
Code: Select all
{if $smarty.post.submit}
show registered content
{else}
show registration form
{/if}
New Site Coming Soon! Stay tuned 
Re: If Form Was Submitted
Yeah that works. But it can be done differently, you can post different types of hidden fields, so the first form has a hidden field called form-1, the second form-2 and so on, and so on. That way you can both check the information, if the form was submitted but also if there`s more to it then 1 form, which sometimes is the case ( more then 1 form that is.. )
Anyway, works the same way as Torni told you, except you don`t check if $_POST[''submit] rather, $_POST['step-1'] et cetera.
Anyway, works the same way as Torni told you, except you don`t check if $_POST[''submit] rather, $_POST['step-1'] et cetera.
Re: If Form Was Submitted
Thanks, your code was easy to follow and understand. I hope to add this code soon to my registration script and maybe start accepting registrations for character name reservations
.
Sincerely,
Aleeious
Sincerely,
Aleeious