PHP Login System with Admin Features

This forum was created to talk about the PHP Login System with admin features created by jpmaster77 on evolt's website


    Adding date of birth field

    Share
    avatar
    Dorji

    Number of posts : 25
    Registration date : 2009-03-30

    Adding date of birth field

    Post  Dorji on Mon Mar 30, 2009 11:46 pm

    Help me with date of birth field....
    I have created dob field in database. Since there are mysql takes date formate in yyyy-mm-dd format. and the dob filled by the user from form is of 3 (which is drop down list. i am have having trouble with combining these three variable from the form.

    PLEASE HELP ME.
    avatar
    Linchpin311

    Number of posts : 220
    Age : 32
    Localisation : Long Island
    Registration date : 2007-05-14

    Re: Adding date of birth field

    Post  Linchpin311 on Tue Mar 31, 2009 1:41 am

    why not just check their values in session.php and if they check out, format them there. you can put them in a variable once they are formatted to your liking then you can pass that variable to database.php and insert it into the database.


    _________________
    in the end, the universe tends to unfold as it should...

    Also note that it is your responsibility to die() if necessary.
    avatar
    Dorji

    Number of posts : 25
    Registration date : 2009-03-30

    Re: Adding date of birth field

    Post  Dorji on Wed Apr 01, 2009 9:08 am

    hi here is the code but is doesnt seem to work help!!
    From option in update user
    Code:
    <select name="date">
    <?
    for($index=1; $index <= 31; $index++)
    echo "<option value='$index'>$index</option>";
    ?>
    </select>

    <!-- generate a list of years to select -->

    <select name="year">
    <?
    for($index=1995; $index >=1900 ; $index--)
    echo "<option value='$index'>$index</option>";
    ?>
    </select>
    then in process.php under function procEditAccount()
    i have added
    Code:
    $retval = $session->editAccount($_POST['curpass'], $_POST['newpass'], $_POST['email'],$_POST['date'],$_POST['month'],$_POST['year']);
    then in session.php under function editAccount() i broght those values
    and i am struck in it while combining those three values into one
    when i combine without a function during it works well. but with function the value is not entering
    thanks
    avatar
    Linchpin311

    Number of posts : 220
    Age : 32
    Localisation : Long Island
    Registration date : 2007-05-14

    Re: Adding date of birth field

    Post  Linchpin311 on Wed Apr 01, 2009 8:26 pm

    i dont have nearly enough information about what you are trying to do or what you say isnt working to adequately advise you on a course of action...

    i understand you wish to give your users the ability to edit their date of birth via the procEditAccount function but i really need to know exactly what isnt working for you in order to find a way to fix it. without seeing the full picture, i can say that what you posted looks good but without seeing your edits to session.php (and possibly to database.php) i cant tell whats going wrong.

    why dont you post some code from these files and maybe some of the error messages php is giving you, then we can take it from there.


    _________________
    in the end, the universe tends to unfold as it should...

    Also note that it is your responsibility to die() if necessary.
    avatar
    Dorji

    Number of posts : 25
    Registration date : 2009-03-30

    Re: Adding date of birth field

    Post  Dorji on Sat May 02, 2009 10:06 pm

    well finally i got my code work i am post for you all
    step 1
    Make a column in users table
    Code:
    ALTER TABLE `users` ADD `dob` DATE NOT NULL ;

    add the code below to the register.php
    Code:
    <tr>
                         <td width="110"><p><b>Date of Birth:</b></p></td>
                            <td><p>
    <select name="month"><option value="0" Selected>Select</option>
    <option value="1">January</option>
    <option value="2">February</option>
    <option value="3">March</option>
    <option value="4">April</option>
    <option value="5">May</option>
    <option value="6">June</option>
    <option value="7">July</option>
    <option value="8">August</option>
    <option value="9">September</option>
    <option value="10">October</option>
    <option value="11">November</option>
    <option value="12">December</option>
    </select>

    <!-- generate a list of available days in a month, 1 to 31 -->

    <select name="date">
    <option value="0" selected>--</option>
    <?
    for($index=1; $index <= 31; $index++)
    echo "<option value='$index'>$index</option>";
    ?>
    </select>

    <!-- generate a list of years to select -->

    <select name="year">
    <option value="0" selected>----</option>
    <?
    for($index=1995; $index >=1900 ; $index--)
    echo "<option value='$index'>$index</option>";
    ?>
    </select></p>
    </td><td><p> <?echo $form->error("date"); ?><p></td>

                         </tr>


    Now in process.php under proregister() function add.
    Code:

    $retval = $session->register($_POST['user'], $_POST['pass'], $_POST['email'],$_POST['sname'],$_POST['year'],$_POST['month'],$_POST['date']);
         
    three field date,month and year.


    Now in session.php
    add following line under register() function.

    Code:
    function register($subuser, $subpass, $subemail,$year,$month,$date){
    ...
    some code
    ..
     $field="month";
        if($month == 0 || $date== 0 || $year==0){
            $form->setError($field, "* Please Select Birth Date");
            }
    /*Add above line above */
    /* Email error checking */
    ...
    Some code
    ..

    /*add this  line as shown*/

          /* Errors exist, have user correct them */
          if($form->num_errors > 0){
            return 1;  //Errors with form
          }
          /* No errors, add the new account to the */
        else{ $date2=$year.'-'.$month.'-'.$date;

            if($database->addNewUser(md5($subemail), md5($subpass), $subemail,$date2)){

    /*some code*/


    Now in database.php add the following lines in addNewUser().
    Code:

      function addNewUser($username, $password, $email,$date){
    $q = "INSERT INTO ".TBL_USERS." VALUES ('$username','$sname', '$password', '0', $ulevel, '$email','$date', $time)";


    Thats all
    avatar
    michaelsam

    Number of posts : 4
    Registration date : 2009-02-26

    don't works for me

    Post  michaelsam on Fri Aug 28, 2009 3:17 pm

    i tried many things, but this script don't works for me
    every time i get a error with the date (day) at registration
    my order is day month year at registration
    when i delete the day i get an error with the month

    so what is wrong can you help me please ?
    avatar
    michaelsam

    Number of posts : 4
    Registration date : 2009-02-26

    Re: Adding date of birth field

    Post  michaelsam on Sat Aug 29, 2009 8:22 am

    i got this workin now too
    the same solution as with the other
    the order of asking for in process.php and session.php

    [code]..,$subdate, $submonth, $subyear, $subgender, $subaccept_terms, $subnumLogins){[/code}]

    Sponsored content

    Re: Adding date of birth field

    Post  Sponsored content


      Current date/time is Sun Oct 22, 2017 4:52 pm