Page 1 of 1

Allowing users to register as male or female

Posted: Tue Jul 26, 2011 8:19 pm
by BluePixel
Is this code correct
<?php
if(isset($_POST['submit'])) {
     if($_POST['user_gender'] == 1) {
          
     $user_gender = male;
	
	 }
	 
	 if($_POST['user_ender'] == 2) {
		 
	 $user_gender = female;
	
	}else{
	 
         echo "you must select a gender";
          
     }
}
?>
Am I going in the right direction? Any tutorials?

Re: Allowing users to register as male or female

Posted: Tue Jul 26, 2011 8:22 pm
by jacek
It looks like it is heading in the right direction, but obviously needs completing ;)

Re: Allowing users to register as male or female

Posted: Tue Jul 26, 2011 10:10 pm
by Dylan
Obviously, as Jacek send, it needs completion; I thought I'd point out to you also in case you're getting silly syntax errors:
if($_POST['user_ender'] == 2) {
Has a typo on it:
if($_POST['user_gender'] == 2) {

Re: Allowing users to register as male or female

Posted: Wed Jul 27, 2011 7:45 am
by Linkjuice57
I would do;
If user_gender == 2 { female }
else { male }
And just set the radio buttons to 'male' by default