Allowing users to register as male or female

Ask about a PHP problem here.
Post Reply
BluePixel
Posts: 7
Joined: Tue Jul 19, 2011 9:18 am

Allowing users to register as male or female

Post 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?
User avatar
jacek
Site Admin
Posts: 3262
Joined: Thu May 05, 2011 1:45 pm
Location: UK
Contact:

Re: Allowing users to register as male or female

Post by jacek »

It looks like it is heading in the right direction, but obviously needs completing ;)
Image
User avatar
Dylan
Posts: 150
Joined: Fri May 06, 2011 7:14 pm

Re: Allowing users to register as male or female

Post 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) {
User avatar
Linkjuice57
Posts: 23
Joined: Tue Jul 12, 2011 2:44 pm

Re: Allowing users to register as male or female

Post by Linkjuice57 »

I would do;
If user_gender == 2 { female }
else { male }
And just set the radio buttons to 'male' by default
non-existent PHP newb
Post Reply