Jump to content

HELP! Passing this Field!


Deanznet

Recommended Posts

Better to do some checking.

 

<?php
if(intval($_GET['dd']) == 0 || intval($_GET['Month']) == 0 || intval($_GET['Yr'])){
   //error
}
else{
   if(!checkdate($_GET['Month'],$_GET['dd'],$_GET['Yr'])){
      //error - isn't really a date (32 of Feb etc?)
   }
   else{
      $dob = mysql_real_escape_string($_GET['Yr'].'-'.$_GET['Month'].'-'.$_GET['dd']);
      $query = "INSERT INTO tablename (id,dob) VALUES ('$id','$dob')";
      $insert = mysql_query($query) or trigger_error(mysql_error());
      
      if($insert == 1){
         //row was inserted - success
      }
   
   }
}
?>

Okay this is a date of birth... Drop down menu...

 

I need to pass it in this format dd-m-yr

 

Okay i have 3 drop down menus dd  and Month and Yr

 

i need to combin all these into 1 field and make the variable birthdate if you understand. Hpw!?

 

Why do you need to pass it in dd - m - yr format? By doing that you lose out on some pretty powerful MySQL date functions. Surely you should add it to a date column, and if needs be, re-format the date after extraction to suit your needs?

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.