Anxious Posted April 8, 2009 Share Posted April 8, 2009 <tr><td><p><br> Date of Birth:<br> </p> </td> <td><br> <select name="select1" id="select1"> <option value="" selected></option> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> <option value="6">6</option> <option value="7">7</option> <option value="8">8</option> <option value="9">9</option> <option value="10">10</option> <option value="11">11</option> <option value="12">12</option> <option value="13">13</option> <option value="14">14</option> <option value="15">15</option> <option value="16">16</option> <option value="17">17</option> <option value="18">18</option> <option value="19">19</option> <option value="20">20</option> <option value="21">21</option> <option value="22">22</option> <option value="23">23</option> <option value="24">24</option> <option value="25">25</option> <option value="26">26</option> <option value="27">27</option> <option value="28">28</option> <option value="29">29</option> <option value="30">30</option> <option value="31">31</option> </select> <select name="select1" id="select1"> <option value="" selected></option> <option value="January">January</option> <option value="February">February</option> <option value="March">March</option> <option value="April">April</option> <option value="May">May</option> <option value="June">June</option> <option value="July">July</option> <option value="August">August</option> <option value="September">September</option> <option value="October">October</option> <option value="November">November</option> <option value="December">December</option> </select> <select name="select1" id="select1"> <option value="" selected></option> <option value="2009">2009</option> <option value="2008">2008</option> <option value="2007">2007</option> <option value="2006">2006</option> <option value="2005">2005</option> <option value="2004">2004</option> <option value="2003">2003</option> <option value="2002">2002</option> <option value="2001">2001</option> <option value="2000">2000</option> <option value="1999">1999</option> <option value="1998">1998</option> <option value="1997">1997</option> <option value="1996">1996</option> <option value="1995">1995</option> <option value="1994">1994</option> <option value="1993">1993</option> <option value="1992">1992</option> <option value="1991">1991</option> <option value="1990">1990</option> <option value="1989">1989</option> <option value="1988">1988</option> <option value="1987">1987</option> <option value="1986">1986</option> <option value="1985">1985</option> <option value="1984">1984</option> <option value="1983">1983</option> <option value="1982">1982</option> <option value="etc">etc</option> </select></td><td><br> <? echo $form->error("DOB"); ?></td> </tr> "<? echo $form->error("DOB"); ?>" is the error field, I need a value field eg: <? echo $form->value("DOB"); ?> please somewhere, what my question is, how would I set it so that the three, values, would enter in the database under DOB in the format of, "14/January/1993" etc. If you would like me to paste the code with all the other fields in (Username, password etc) let me know. Thanks Quote Link to comment Share on other sites More sharing options...
schilly Posted April 8, 2009 Share Posted April 8, 2009 Just concatenate your fields together $dob = $_POST['month'] . "/" . $_POST['day'] . "/" . $_POST['year']; can you edit your post so we can see your question better. the code tag is missing / at the bottom Quote Link to comment Share on other sites More sharing options...
Anxious Posted April 8, 2009 Author Share Posted April 8, 2009 Yeah, I did that as I realised it was all included, and yeah, thats what I thought (I'd have to edit the names then, and put seperate values in) Just not sure, where i'd include it. <?php function addNewUser($username, $password, $email, $gender, $location){ $time = date("F j, Y, g:i"); /* If admin sign up, give admin user level */ if(strcasecmp($username, ADMIN_NAME) == 0){ $ulevel = ADMIN_LEVEL; }else{ $ulevel = USER_LEVEL; } $q = "INSERT INTO ".TBL_USERS." ('username','password','ulevel','email','time','gender','location')VALUES ('$username', '$password', $ulevel, '$email', '$time', '$gender', '$location')"; return mysql_query($q, $this->connection); } ?> Thats putting the values in the database. It has this; $time = date("F j, Y, g:i"); For doing the DOB would it be something like, $dob = $_POST['day'] . "/" . $_POST[month'] . "/" . $_POST['year']; As you posted. So it'd be $time = date("F j, Y, g:i"); $dob = $_POST['day'] . "/" . $_POST[month'] . "/" . $_POST['year']; Is that the idea you meant? Quote Link to comment Share on other sites More sharing options...
schilly Posted April 8, 2009 Share Posted April 8, 2009 ya pretty much. if you're always going to be displaying the dob as mm/dd/yy then just store it like that in a string. if you need to manipulate it at all, i would use mktime and store it as an int but it's all preference. Quote Link to comment Share on other sites More sharing options...
Anxious Posted April 8, 2009 Author Share Posted April 8, 2009 Ok thanks, so the whole database code would look like this? <?php function addNewUser($username, $password, $email, $day, $month, $year, $location, $gender){ $time = date("F j, Y, g:i"); $dob = $_POST['day'] . "/" . $_POST['month'] . "/" . $_POST['year']; /* If admin sign up, give admin user level */ if(strcasecmp($username, ADMIN_NAME) == 0){ $ulevel = ADMIN_LEVEL; }else{ $ulevel = USER_LEVEL; } $q = "INSERT INTO ".TBL_USERS." ('username','password','ulevel','email','time','gender','location','dob')VALUES ('$username', '$password', $ulevel, '$email', '$time', '$gender', '$location', '$day', '$month', '$year')"; return mysql_query($q, $this->connection); } ?> [code] I'm guessing 'INSERT INTO etc etc, is wrong. Thanks Quote Link to comment Share on other sites More sharing options...
schilly Posted April 8, 2009 Share Posted April 8, 2009 just change '$day', '$month', '$year' to '$dob' because we made it one variable now. Quote Link to comment Share on other sites More sharing options...
Anxious Posted April 8, 2009 Author Share Posted April 8, 2009 Okay, thanks What about, using date of birth, if I wanted to get the age out of the database using date of birth, so If I put in, 10/June/1993, and I wanted to pull out the age, which is 15, how would I do that? Quote Link to comment Share on other sites More sharing options...
schilly Posted April 8, 2009 Share Posted April 8, 2009 grab the year,month,day from the string using substr then get the current year,month,day via date("",time()) and compare. see now if your doing manipulation on the date i find it easier to store it as an int. then you can get any date info from it via the date function instead of having to parse a string. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.