PDA

View Full Version : group id


Lionel
03-16-2002, 05:05 PM
I'd like at registration have users choose from an option list and depending of the choice, that will determine their group id automatically. How would I code that in register.php?

instead of $newusergroupid=2;
something like :
$newusergroupid={form groupid};
______________________________________________
in order to simplify the process, I am willink to forget about the verify email part, unless someone tells me how to handle that, once the email has been verified, to insert it into the pre-chosen group.
_________________________________________
if ($verifyemail) {
$newusergroupid=3;
} else {
if ($moderatenewmembers or $coppauser) {
$newusergroupid=4;
} else {
$newusergroupid=2;
}

Logician
03-21-2002, 12:48 PM
(Not tested, writing on the fly!) ;)

If you designed your option's HTML code, it should have a variable name (HTML form object name) which will be known as the same name in your register.php. So lets say that you have a HTML code like that:

<select name="job">
<option value="lawyer" selected>Lawyer</option>
<option value="doctor">Doctor</option>
<option value="engineer">Engineer</option>
</select>

When this form is submitted, you will have a "$job" variable with a value of "lawyer" or "doctor" or "engineer" in your PHP code..

Then all you have to do is check its value with a simple if statement:
if ($job=="lawyer") {$newusergroupid=2;}
elseif ($job=="doctor") {$newusergroupid=3;}
else {$newusergroupid=4;}

Hope this helps..

Regards,
Logician