SitePoint Sponsor

User Tag List

Results 1 to 9 of 9

Thread: how to make a question box before site loads?

  1. #1
    SitePoint Enthusiast
    Join Date
    Nov 2011
    Posts
    56
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    how to make a question box before site loads?

    How do I make a question box on home page where a visitor has to answer before they enter the site? Is there a blog/tutorial someone could point me to maybe? -Thanks

  2. #2
    i want cake and cookies Stomme poes's Avatar
    Join Date
    Aug 2007
    Location
    Netherlands
    Posts
    9,997
    Mentioned
    41 Post(s)
    Tagged
    1 Thread(s)
    Like asking for a login? I would make the question page the index.html (root) of the site. If the answer needs to be a real answer, you'll need a back-end script to check the answer before serving them another page (mainpage.html or whatever) representing your "front page".

    If it doesn't matter what they answer, just have the submit button of the form on index.html take the user to mainpage (set the method to GET and the action to the url of mainpage.html).

    (of course if it really is a login, just leave main page at index.html and have the server request authentication)

    If you're thinking of a kind of modal dialog, where the user loads the mainpage.html but gets a dark overlay and a popupish thing in the middle of the screen, know that anyone with a slow enough connection will have plenty of time to see the mainpage.html before the popup gets initiated. But if that's what you're after, just do some search-engine searching for "css modal dialog" or with Javascript.

  3. #3
    SitePoint Enthusiast
    Join Date
    Nov 2011
    Posts
    56
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The question will have a specific answer.

  4. #4
    The CSS Clinic is open silver trophybronze trophy
    SitePoint Award Recipient Paul O'B's Avatar
    Join Date
    Jan 2003
    Location
    Hampshire UK
    Posts
    37,781
    Mentioned
    99 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by nlsilverberg View Post
    The question will have a specific answer.
    I'm sorry but that reply is unlikely to endear you to the forums and unless you reply in full to Stomme Poes's specific queries then it is likely that no one else will step in to help you.

    We need to know exactly what you want to do as your question is ambiguous and could be as simple as password protecting your folder via your hosts control panel or it could be that you want a whole back end built with php/mysql to cater for specific users. Or you just might want the default js alert box to pop up.

  5. #5
    ♪♪ ♪ ♪ ♪ ♪♪ ♪ ♪♪ Markdidj's Avatar
    Join Date
    Sep 2002
    Location
    Bournemouth, South UK
    Posts
    1,551
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Are you sure you're in the right place for this?

    Server-side code would be better, otherwise I could just turn javascript off and see you page, or follow your javascript and inject the result your page is looking for.
    LiveScript: Putting the "Live" Back into JavaScript
    if live output_as_javascript else output_as_html end if

  6. #6
    The CSS Clinic is open silver trophybronze trophy
    SitePoint Award Recipient Paul O'B's Avatar
    Join Date
    Jan 2003
    Location
    Hampshire UK
    Posts
    37,781
    Mentioned
    99 Post(s)
    Tagged
    3 Thread(s)
    Moved to PHP forum

  7. #7
    SitePoint Enthusiast
    Join Date
    Nov 2011
    Posts
    56
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I am not sure what to use, javascript or php or what. I was hoping to get a point to a tutorial or blog showing...
    When a user visits a site, before the page loads I would like a small box (or something, just something simple) to come up (a question). This question will have a specific answer. The user can only enter the site if the correct answer is inputed into the box.

  8. #8
    The CSS Clinic is open silver trophybronze trophy
    SitePoint Award Recipient Paul O'B's Avatar
    Join Date
    Jan 2003
    Location
    Hampshire UK
    Posts
    37,781
    Mentioned
    99 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by nlsilverberg View Post
    I am not sure what to use, javascript or php or what. I was hoping to get a point to a tutorial or blog showing...
    When a user visits a site, before the page loads I would like a small box (or something, just something simple) to come up (a question). This question will have a specific answer. The user can only enter the site if the correct answer is inputed into the box.
    You could as Stomme Poes said above just create a separate page for this function with a form on it asking that question and then submit the form and depending on the data returned send the user to the page you want.

    If you want a login of some sort then there are plenty of examples about.

    Or are you talking about creating a captcha.

  9. #9
    Keeper of the SFL StarLion's Avatar
    Join Date
    Feb 2006
    Location
    Atlanta, GA, USA
    Posts
    3,539
    Mentioned
    31 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    <?php
    session_start
    ();
    if(!isset(
    $_POST['qanswer']) && !isset($_SESSION['answered'])) {
     
    //Display question
     
    die();
    } elseif(isset(
    $_POST['qanswer']) && $_POST['qanswer'] == "TheRealAnswer") {
    $_SESSION['answered'] = 1;
    }
    //Display page
    Never grow up. The instant you do, you lose all ability to imagine great things, for fear of reality crashing in.

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
  •