Results 1 to 6 of 6

Thread: Date stamp
      
   

  1. #1
    Lageo04 is offline Corporal
    Join Date
    Jul 2006
    Posts
    14

    Default Date stamp

    I've created a registration page using David's contact mail-to form.
    I've added lines to the processing page to also enter data into my sql.
    All is working great.
    I'd like to add a date stamp to the data base. I've already added the column to my data table in My Sql. Now I don't know what I need to add to the processing page to make this entry happen.
    It's probably a simple line but I don't have a clue.
    Thanks in advance
    George

  2. #2
    Join Date
    Mar 2006
    Location
    Mallorca, Spain
    Posts
    6,313

  3. #3
    Lageo04 is offline Corporal
    Join Date
    Jul 2006
    Posts
    14

    Default Re: Date stamp

    Hi David:
    That's where I'm lost. I know the process page has to have something in it so it can enter the date data into my sql.
    This is the process page:

    <?PHP
    // Receiving variables
    @$firstname = addslashes($_POST['firstname']);
    @$lastname = addslashes($_POST['lastname']);
    @$username = addslashes($_POST['username']);
    @$email = addslashes($_POST['email']);
    @$comments = addslashes($_POST['comments']);
    $commentsl = ereg_replace('@', '(.)', $commentsl);
    // error checking
    if (strlen($firstname) == 0 )
    {
    header("Location: name_error.html");
    exit;
    }
    if (strlen($lastname) == 0 )
    {
    header("Location: name_error.html");
    exit;
    }
    if (strlen($username) == 0 )
    {
    header("Location: user_error.html");
    exit;
    }
    if (strlen($email) == 0 )
    {
    header("Location: email_error.html");
    exit;
    }
    if (! ereg('[A-Za-z0-9_-]+\@[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+', $email))
    {
    header("Location: email_error.html");
    exit;
    }
    if (substr_count($comments, '@') > "2")
    {
    header("Location: comments_error.html");
    exit;
    }
    //Sending Email to form owner
    $mailto = "xxxxxxx@xxxxxxx";
    $mailsubj = "Feedback from My website form";
    $mailhead = "From: $email\n";
    reset ($HTTP_POST_VARS);
    $mailbody = "Values submitted from my web site form:\n";
    while (list ($key, $val) = each ($HTTP_POST_VARS))
    {
    $mailbody .= "$key : $val\n";
    }
    mail($mailto, $mailsubj, $mailbody, $mailhead);
    $link = mysql_connect("localhost","xxxxxxx","xxxxxxxx");
    mysql_select_db("xxxxxxxx_frgn1",$link);
    $query="insert into members (first_name,last_name,user_name,email,comments) values ('".$firstname."','".$lastname."','".$username."', '".$email."','".$comments."')";
    mysql_query($query);

    header("Location: confirmationpage.html");
    ?>

    I'm not even sure if something has to be in the form page also.
    Any help will be appreciated.
    Thanks George

  4. #4
    Join Date
    Mar 2006
    Location
    Mallorca, Spain
    Posts
    6,313

    Default Re: Date stamp

    There must be a database command which would add
    the date but if you add the 3 lines as seen below in receiving variables
    it should work............

    You will also have to add these 3 fields to your form as well

    day
    month
    year

    Lastly you will have to add them to your database code....

    have fun, and please let us know how you get on.


    // Receiving variables
    @$firstname = addslashes($_POST['firstname']);
    @$lastname = addslashes($_POST['lastname']);
    @$username = addslashes($_POST['username']);
    @$email = addslashes($_POST['email']);
    @$comments = addslashes($_POST['comments']);
    @$day = addslashes($_POST['day']);
    @$month = addslashes($_POST['month']);
    @$year = addslashes($_POST['year']);

  5. #5
    Lageo04 is offline Corporal
    Join Date
    Jul 2006
    Posts
    14

    Default Re: Date stamp

    That would be the easy way, but I like to make things difficult.
    I'm looking for a way to date stamp when the form is filled out so that it will automatically enter the date in the data base.
    If I'm right, there has to be some sort of code in the form page to pickup the current date so it can be processed for entry into the database without having to be manually inserted in the form page.

  6. #6
    navaldesign's Avatar
    navaldesign is offline General & Forum Moderator
    Join Date
    Oct 2005
    Location
    Italy
    Posts
    12,115

    Default Re: Date stamp

    Ok, it depends on many things. Some use the "time" but in that case you would need some lines of code to convert time in a recognizable format (time is simply a number). So i suggest you do this:

    Add this line in your script, anywhere before the DB writing part:

    $date = date("l jS F Y, g:i A");

    Then add the string $date in your database, excactly as you do for the other strings.

    The code should be in the script, NOT in the form. Of course, this will give you the server date and time, if there is time difference between your location time and the server time, you will need some times of code to correct this difference (if it is so important) .
    Navaldesign
    Logger Lite: Low Cost, Customizable, multifeatured Login script
    Instant Download Cart: a Powerfull, Customized, in site, DB driven, e-products Cart
    DBTechnosystems.com Forms, Databases, Shopping Carts, Instant Download Carts, Loggin Systems and more....
    Advanced BlueVoda Form Processor : No coding form processor! Just install and use! Now with built in CAPTCHA!


Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49