Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Page 1 of 5 1 2 3 ... LastLast
Results 1 to 10 of 47
  1. #1
    Lor
    Lor is offline
    Member Lor's Avatar
    Join Date
    Mar 2003
    Posts
    39
    Member #
    795
    I do not know the exact name of the function I am looking to write (thus, I can't really locate any information on it), so I will just describe what I want to do.

    I want to put in a deadline for submitting a form. Specifically, I want users to be unable to submit form results after 12:00 P.M. on Sundays. For example, clicking the 'submit' button at 11:59 A.M. Sunday, or earlier, will have normal results; but if hitting 'submit' at noon or later, will result in a pop-up alert declaring the missed deadline.

    What is this type of function called (I don't even know if it is proper to refer to it as a function)? Which type of code is used? Where can I go to get the script/learn more about it? Anything ideas? Anything will help, really.

    Thanks

  2.  

  3. #2
    WDF Staff smoseley's Avatar
    Join Date
    Mar 2003
    Location
    Boston, MA
    Posts
    9,729
    Member #
    819
    Liked
    205 times
    You're going to want to do this on the server side. Because you want this to be fair, you want everyone submitting the form relative to the same clock (the one on the server). Also, you don't want people changing the clocks on their local computers to manipulate the system. You will have to use a server-side programming language to determine when the form is submitted. There are many to choose from (PHP, ASP, Java, CGI, etc.), and each has its own implementation of date functionality. I suggest you find out what programming languages (if any) your web server supports and then repost your question

  4. #3
    Lor
    Lor is offline
    Member Lor's Avatar
    Join Date
    Mar 2003
    Posts
    39
    Member #
    795
    Well, my server says it supports Perl, C++, TCL, Python, and PHP4. But I wrote everything in html, javascript, and CSS since that's all I really know at the moment. If I can write the script I want in one of the languages I already know, I would prefer to do so; but if I have to start learning one of the other languages to do what I want, I am up for it.

  5. #4
    WDF Staff smoseley's Avatar
    Join Date
    Mar 2003
    Location
    Boston, MA
    Posts
    9,729
    Member #
    819
    Liked
    205 times
    You should do this in PHP. It is the easiest and has the largest user-base of all of those languages.

    It doesn't matter that you wrote everything else in HTML and JS. Those are both client-side scripts/markups.

    Here's what you should do. Create a new page that the form will submit to. Call it "form_process.php" or something along those lines. This page will process the form that is submitted and determine whether it will be accepted.

    Then, in your page with your form, make it look something like this:
    Code:
    <form action="form_process.php" method="post">
    <!-- Put your form in here -->
    </form>
    form_process.php will look something like this:
    PHP Code:
    <?php
    $now 
    getdate();
    // Check to see that the form was submitted before 7/11/2003 12:00:00
    if ($now["year"] == 2003 && $now["mon"] == && $now["mday"] <= 11 && $now["hours"] < 12) {
        
    //Here is where you will process your form
        
    header("Location:success.htm");
    } else {
        
    header("Location:failure.htm");
    }

    ?>
    Someone else can clean it up better for you. I'm gonna move the post to the PHP forum.

  6. #5
    JR
    JR is offline
    Senior Member JR's Avatar
    Join Date
    Nov 2002
    Location
    UK
    Posts
    4,354
    Member #
    257
    remember to use the php opening and closing tags around the code <?php and ?>
    JR

  7. #6
    Lor
    Lor is offline
    Member Lor's Avatar
    Join Date
    Mar 2003
    Posts
    39
    Member #
    795
    OK, I am new to php, and am having some problems, so a few questions ...

    1) Upon submitting the form, the 'from-results.php' page 'cannot be found'. I just created a file in my control panel and pasted the script you gave me; is there anything else I should write into the page in order for it to be usable? Anything at all, no matter how obvious it might seem to you?

    2) Will changing the "action" data affect the validation scripts I already have in place for the form? In other words, there is already something else following the "action" command; will tampering with this affect other functions of the form?

    3) I have the results of the form being sent to a .txt file for me to read. Will I still be able to do this is I get this php function enabled?

    Thanks for your help

  8. #7
    JR
    JR is offline
    Senior Member JR's Avatar
    Join Date
    Nov 2002
    Location
    UK
    Posts
    4,354
    Member #
    257
    1. You put from_results.php, do you mean form_results.php (that could be your problem)

    2. If you attach your form page i can take a look

    3. Why not have the form results put into a database or emailed you, that would be better

    As i said, if you attach your form i can help you with the php coding
    JR

  9. #8
    Lor
    Lor is offline
    Member Lor's Avatar
    Join Date
    Mar 2003
    Posts
    39
    Member #
    795
    I actually called the file 'picks.php', not form_results.php; so I don't think that was the problem.

    I am still learning about SQL, so I am not having the data sent to the database yet; and I would like all of the information submitted by everyone in one place so I can view the results conveniently; thus, I would rather not have the results submitted via e-mail.

    I attached the form, as you requested. I am sure it is not all that tidy, so I hope you can sift through it and make some sense. Thanks.

  10. #9
    JR
    JR is offline
    Senior Member JR's Avatar
    Join Date
    Nov 2002
    Location
    UK
    Posts
    4,354
    Member #
    257
    Your problem is here
    Code:
    <form method="POST" action....
    Take out the onsubmit because there is a location redirect in the PHP code transio gave you and action needs to be picks.php.

    The code transio supplied however will not do anything with the results of your form, to do this you will need to use $_POST['elementname'] for each element in the form. I do not know how to add these to a text file, i only know how to e-mail and add to a database so i will look into this (unless somebody with more knowledge can answer that). I will probably make a PHP file for you (if i have time) to process the form, is the page you attached on the internet anywhere?
    JR

  11. #10
    WDF Staff smoseley's Avatar
    Join Date
    Mar 2003
    Location
    Boston, MA
    Posts
    9,729
    Member #
    819
    Liked
    205 times
    Lor, you should probably add a Turtle Dollars reward in a new post for JR to make the file for you. That's a lot of work


Page 1 of 5 1 2 3 ... LastLast

Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 01:18 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com