I have a form that allows users to register on the site. It uses something like the following code portion. First time through, register.php asks the user for an email address. Next time through (initial screen), it does some checking on that email to see if it is already being used. The last time through (register), it displays the registration fields.
register.php
switch (@$_POST['do'])
{
case "register":
# display registration fields for input by user
include("register_form.inc"); # this contains the hidden 'do' field and gets posted back to register.php
break;
case "initial_screen":
# do stuff for checking initial email answer from user
$preScreen = 'n';
include("register_form.inc");
break;
default:
# display initial email input
$preScreen = 'y';
include("register_form.inc");
}
This code works fine for registering a user. However, I'd like to reuse it for allowing the user to edit their profile. I need most of the logic that exists in the "register" case above (first case section), but I want to go directly to that section first if the user exists and just wants to edit their profile info. Furthermore, I'm trying to not have the user go to a form as an interim step that has a hidden field where I could set the value of the "do" field to "register". I am also trying to avoid passing values in the URL for secuity reasons. Finally, I'm trying to limit the amount of JavaScript (which could be used to auto-submit the form) if I can. Ideally, I'd like to keep this in the php/HTML world.
I thought about having another php script that would be a "wrapper program"of sorts. This program would be called when the user wants to edit the profile, would set variables and then include the register.php script. I'm not sure how to deal with the fact that the case statement works off of a POST variable. Does anyone have any suggestions?
Thanks,
Michael