Jump to content

Date of birth details on registering


graham23s

Recommended Posts

Hi Guys,

 

on my registration form i have this:

 

  echo ("<tr>");
  echo ("<td align=\"right\"><b>Date Of Birth:</b></td><td align=\"left\"><select name=\"month\"><option value=\"0\">-------</option>");
       foreach($months_list as $value) {
       
         echo '<option value="'.$value.'">'.$value.'</option>';
       
       }
  echo ("</select>");
  echo ("<select name=\"day\"><option value=\"0\">--</option>");     
       
       foreach($days as $value) {
    
         echo '<option value="'.$value.'">'.$value.'</option>';   
       
       }
  echo ("</select>");
  echo ("<select name=\"year\"><option value=\"0\">----</option>");     
       
       foreach($years as $value) {
    
         echo '<option value="'.$value.'">'.$value.'</option>';   
       
       }  
  echo ("</select><span class=\"star\">*</span></td>");
  echo ("</tr>");

 

which works fine (looks wise) if the user doesn't select any of the 3 fields it's left as: 0

 

when i process the data i did:

 

<?php
     ## dob fields filled in
     if(($month == 0) || ($day == 0) || ($year == 0)) {
     stderr("Error","Your date of birth details aren't filled in correctly please fill them all in.");
     include("includes/footer.php");
     exit;      
     }
?>

 

so if any of the 3 fields weren't set display an error, but when i fill them in properly i still get the error, any ideas on my logic it looks ok i think lol

 

cheers guys

 

Graham

Link to comment
https://forums.phpfreaks.com/topic/81826-date-of-birth-details-on-registering/
Share on other sites

Well it looks like you have coded your script for if 'register_globals' is turned on, and its better for you to code your script using the superglobals $_POST or $_GET

 

You could re-code your script as:

 
if (empty($_POST['month']) || empty($_POST[['day']) || empty($_POST['year']))

(Of course replace the $_POST with $_GET if your form uses GET

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.