Jump to content

HELP! Passing this Field!


Deanznet

Recommended Posts

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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?

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.