Results 1 to 2 of 2

Thread: Obligatory Form

  1. #1
    Join Date
    Apr 2006
    Posts
    205
    Thanks
    11
    Thanked 0 Times in 0 Posts

    Question Obligatory Form

    Hello. Firstly, I'm very, very, very new to PHP and not certain it's what i need for this, so please feel free to point me to a better section of the forums if that's appropriate.

    I want to make a page that has an obligatory form infront of it. i.e. when you access the page a form pops up in front, and you have to fill out the form to make it close.

    I don't want users to have to do this everytime they access the page. Just once.

    How can I make the form obligatory? How will it know if it has been filled out completely or not? Perhaps someone could point me to some examples.

    And secondly what do I need to do to have the website remember when the user correctly fills out the form and not show them the form in future.

    I'm thinking of putting the form within a div that literally blocks the page behind it and using css and javascript to show and hide the div as appropriate.

    Any ideas and or help?

    Thanks,

    dog

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    If you're talking about live interaction, that's javascript, not php.

    If you are ok with submitting the form, then php checking it, which would be MUCH more secure (where javascript can be bipassed), then that's a better option.

    Just have a check...
    PHP Code:
    <?php
    //top of your page:
    if ($_POST['pass'] != "test") {
    echo 
    '<form .......>...</form>'
    exit();
    }
    ?>
    All html goes here. Since the if includes "exit" then this won't be displayed unless the password check verifies.
    There are other ways to do this as well... doesn't need to be a password. Could be a checkbox, etc.
    To make it more complex, you'd want to do something with cookies.
    However, cookies can be faked. As such, you could also include some server side storage (database, I'd suggest) with php, so that you can store the IP address and the "signed in" or not variable, etc. so that the cookie and that must match.
    You could also use sessions, which are a fun little php thing that use cookies and other means to send data from page to page and would keep the user logged in, BUT only for that visit... if they close the window, or come back later, etc. it wouldn't keep them logged in.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

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
  •