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
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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.