PHP and AJAX user registration

I am creating a social network. I hv created a signup form with AJAX and PHP and it works fine. I want to thn create a start page where I collect further information about the user

The problem I am facing is that there are 2 different forms that must display based on the gender of the person as per the signup information

I hv come up with the following code. Has been trying tweaking it but it simply can wk. It only works if I remove the gender conditionals but I need them because I want to ask different questions to men and woman

Furthermore, how can I make the startpage run only once after the intial login and after that upon login, it must go to the profile page?

Thanks in advance

<?php include_once("php_includes/check_login_status.php"); if($user_ok == true) { $u=$log_username; } $sql = "SELECT * FROM users WHERE username='$u' AND activated='1' LIMIT 1"; $user_query = mysqli_query($db_conx, $sql); // Fetch the user row from the query above while ($row = mysqli_fetch_array($user_query, MYSQLI_ASSOC)) { $gender = $row["gender"]; } // Ajax calls this REGISTRATION code to execute if(isset($_POST["f"])){ // CONNECT TO THE DATABASE // GATHER THE POSTED DATA INTO LOCAL VARIABLES $f = preg_replace('#[^a-z0-9]#i', '', $_POST['f']); $l = preg_replace('#[^a-z0-9]#i', '', $_POST['l']); $wt= preg_replace('#[^a-z ]#i', '', $_POST['wt']); $a= preg_replace('#[^a-z ]#i', '', $_POST['a']); $ws= preg_replace('#[^a-z ]#i', '', $_POST['ws']); $c = preg_replace('#[^a-z ]#i', '', $_POST['c']); // FORM DATA ERROR HANDLING if($f == "" || $l == "" || $wt || $a == "" || $ws || $c == "" ){ echo "The form submission is missing values."; exit(); } else { // Add user info into the database table for the main site table $sql = "UPDATE users SET firstname='$f', lastname ='$l', wagsbooty ='$wt', abs ='$a', wagsboobs ='$ws', crash ='$c' WHERE username='$u' LIMIT 1"; $query = mysqli_query($db_conx, $sql); $uid = mysqli_insert_id($db_conx); echo "startup_success"; exit(); } exit(); } ?> Sign Up #startupform{ margin-top:24px; } #startupform > div { margin-top: 12px; } #startupform > input,select { width: 200px; padding: 3px; background: #F3F9DD; } #startupbtn { font-size:18px; padding: 12px; } <?php include_once("template_pageTop.php"); ?>

Fill in this form to create your profile!

Firstname:


Lastname:


<div>
<?php

if($gender === 'm'){
 echo  "WAG with hottest booty :";?></br>
<select id="wagsbooty" onfocus="emptyElement('status')" maxlength="255">
 <?php include_once("template_wags_list.php");
	  
 }else{
  echo "Star with hottest abs:";?></br>
<select id="abs" onfocus="emptyElement('status')" maxlength="255">
 <?php include_once("template_abs_list.php");	
 }
 ?>	 
</select>
</div>
</br>
<div>
<?php	
if($gender === 'm'){
 echo  "WAG with hottest boobs :";?></br>
<select id="wagsboobs" onfocus = "emptyElement('status')" maxlength="255">
 <?php include_once("template_boobs_list.php");
 	 
 }else{
  echo "I have a crash on :";?></br>
<select id="crash" onfocus ="emptyElement('status')" maxlength="255">
 <?php include_once("template_crash_list.php");	
 }
 ?>
 </div>
</select>
</br>

</br>	
<button id="startupbtn" onclick="startup()">Create Profile</button>
<span id="status"></span>
<?php include_once("template_pageBottom.php"); ?> [php][php][/php][/php]
Sponsor our Newsletter | Privacy Policy | Terms of Service