Page 1 of 2 12 LastLast
Results 1 to 10 of 15

Thread: Help with a script to deline members of a certain age

  1. #1
    Join Date
    May 2007
    Location
    South Africa
    Posts
    175
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Help with a script to deline members of a certain age

    Hi folks,

    I have an entry form which has a date of birth input requirement and the format of input is YYYYMMDD i.e 19920819 being born on the 19 August 1992.

    I do however want to limit 1992 models from entering information and should they submit the form then a pop up should appear saying sorry you are too old to enter these events?

    PHP Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <
    html>
    <
    head>
    <
    meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <
    title>entryform</title>
    <
    meta name="KEYWORDS" content="GAUTENG,NORTH">
    <
    meta http-equiv="Page-Enter" content="revealTrans(Duration=1,Transition=2)">
    <
    meta name="GENERATOR" content="Created by BlueVoda">
    <
    style type="text/css">
    div#container
    {
       
    width752px;
       
    positionrelative;
       
    margin-top0px;
       
    margin-leftauto;
       
    margin-rightauto;
       
    text-alignleft;
    }
    body
    {
       
    text-aligncenter;
       
    margin0;
    }
    </
    style>
    <
    script language="JavaScript" type="text/javascript">
    <!--
    function 
    Validateentryform(theForm)
    {
    if (
    theForm.Editbox1.value == "")
    {
       
    alert("Please enter your NAME");
       
    theForm.Editbox1.focus();
       return 
    false;
    }
    if (
    theForm.Editbox1.value.length 3)
    {
       
    alert("Please enter your NAME");
       
    theForm.Editbox1.focus();
       return 
    false;
    }
    if (
    theForm.Editbox1.value.length 35)
    {
       
    alert("Please enter your NAME");
       
    theForm.Editbox1.focus();
       return 
    false;
    }
    if (
    theForm.Editbox4.value == "")
    {
       
    alert("Please enter a value for the \"Please enter your SURNAME\" field.");
       
    theForm.Editbox4.focus();
       return 
    false;
    }
    if (
    theForm.Editbox4.value.length 3)
    {
       
    alert("Please enter at least 3 characters in the \"Please enter your SURNAME\" field.");
       
    theForm.Editbox4.focus();
       return 
    false;
    }
    if (
    theForm.Editbox4.value.length 35)
    {
       
    alert("Please enter at most 35 characters in the \"Please enter your SURNAME\" field.");
       
    theForm.Editbox4.focus();
       return 
    false;
    }
    var 
    strFilter = /^[-+]?\d*\,?\d*$/;
    var 
    chkVal theForm.Editbox3.value;
    if (!
    strFilter.test(chkVal))
    {
       
    alert("Date of Birth ? ? (YYYYMMDD)");
       
    theForm.Editbox3.focus();
       return 
    false;
    }
    if (
    theForm.Editbox3.value == "")
    {
       
    alert("Date of Birth ? ? (YYYYMMDD)");
       
    theForm.Editbox3.focus();
       return 
    false;
    }
    var 
    strFilter = /^[-+]?\d*\.?\d*$/;
    var 
    chkVal theForm.Editbox5.value;
    if (!
    strFilter.test(chkVal))
    {
       
    alert("Please enter your CELL NUMBER (i.e 083 . . . . . . ) no spaces");
       
    theForm.Editbox5.focus();
       return 
    false;
    }
    if (
    theForm.Editbox5.value == "")
    {
       
    alert("Please enter your CELL NUMBER (i.e 083 . . . . . . ) no spaces");
       
    theForm.Editbox5.focus();
       return 
    false;
    }
    if (
    theForm.Editbox5.value.length 10)
    {
       
    alert("Please enter your CELL NUMBER (i.e 083 . . . . . . ) no spaces");
       
    theForm.Editbox5.focus();
       return 
    false

  2. #2
    Join Date
    Nov 2006
    Location
    Northeast USA
    Posts
    408
    Thanks
    8
    Thanked 30 Times in 28 Posts

    Default

    On the processor page, you should convert "19 August 1992" into milliseconds, then convert their entered date to milliseconds, then use a simple if($age<$age18) to check. I suggest looking at http://php.net/manual/en/function.strtotime.php to help you convert the dates automatically.
    -Ben -- THE DYNAMIC DRIVERS
    My Links: My DD Profile||My Youtube Video Tutorials||DD Helping Coders||DD Coders In Training
    I told my client to press F5, the client pressed F, then 5, *facepalm*

  3. #3
    Join Date
    May 2007
    Location
    South Africa
    Posts
    175
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    Hi,

    The conversion of 19 August 19920 is not the challenge. The person inputs the data already in the format of YYYYMMDD and hence to me it would just be an if / else statement whereby . . .if the first four numbers are smaller than 1992 . .. . then you're to old would pop up and submission to MySQL terminated.

    Else submission continues as per normal.

    I just do not know how to do this in php.

    Thanks again for your advice.

  4. #4
    Join Date
    Nov 2006
    Location
    Northeast USA
    Posts
    408
    Thanks
    8
    Thanked 30 Times in 28 Posts

    Default

    Your not seeing the purpose of strtotime. You have to convert both their age and the date into an interger in terms of milliseconds since 1970:
    however you cannot use the YYYYMMDD format. tell them to use YYYY-MM-DD format in order to convert.
    PHP Code:
    $age=strtotime($_POST['age']);
    $agelimit=strtotime("19 August 1992");
    if(
    $age<$agelimit)header("location: error.htm"); 
    -Ben -- THE DYNAMIC DRIVERS
    My Links: My DD Profile||My Youtube Video Tutorials||DD Helping Coders||DD Coders In Training
    I told my client to press F5, the client pressed F, then 5, *facepalm*

  5. #5
    Join Date
    May 2007
    Location
    South Africa
    Posts
    175
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    Thanks for the reply and script.

    In using this script would it be specific to 19 August 1992 or would it be specific to all persons born in 1992?

    Secondly taking your script into consideration where would I insert it using the PHP file presented below?

    The page I refer to is seen at this link
    Regards
    Rob

  6. #6
    Join Date
    Nov 2006
    Location
    Northeast USA
    Posts
    408
    Thanks
    8
    Thanked 30 Times in 28 Posts

    Default

    1st Make sure you change your date entry to YYYY-MM-DD or any other Unix-compatible timestamp.
    2nd. Set your form action to "processor.php"
    3rd Paste the code in that file and it should redirect if the age is less.
    4th Place the rest of your processing code beneath that.
    -Ben -- THE DYNAMIC DRIVERS
    My Links: My DD Profile||My Youtube Video Tutorials||DD Helping Coders||DD Coders In Training
    I told my client to press F5, the client pressed F, then 5, *facepalm*

  7. #7
    Join Date
    May 2007
    Location
    South Africa
    Posts
    175
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    Hi Ben,

    Thanks for the reply.

    As a person who does not have any idea of php - my experiance to do what you ask is very limited -my apologies.

    The information I have been able to give is by using a wysiwyg website builder and therefor can get to show you what I have my apologies - I hope it is also not asking to much.

    Regards
    Rob

  8. #8
    Join Date
    Nov 2006
    Location
    Northeast USA
    Posts
    408
    Thanks
    8
    Thanked 30 Times in 28 Posts

    Default

    Do you have FTP access? Or any type of file access?
    -Ben -- THE DYNAMIC DRIVERS
    My Links: My DD Profile||My Youtube Video Tutorials||DD Helping Coders||DD Coders In Training
    I told my client to press F5, the client pressed F, then 5, *facepalm*

  9. #9
    Join Date
    May 2007
    Location
    South Africa
    Posts
    175
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    Yes I do

  10. #10
    Join Date
    Nov 2006
    Location
    Northeast USA
    Posts
    408
    Thanks
    8
    Thanked 30 Times in 28 Posts

    Default

    Do you have any type of form processor already set up (or maybe built in to the editor). In other-words does the form submit normally now and work?
    -Ben -- THE DYNAMIC DRIVERS
    My Links: My DD Profile||My Youtube Video Tutorials||DD Helping Coders||DD Coders In Training
    I told my client to press F5, the client pressed F, then 5, *facepalm*

Bookmarks

Posting Permissions

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