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

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.

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.

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.

Moved to PHP forum

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.

if(!isset($_POST['qanswer']) && !isset($_SESSION['answered'])) {
 //Display question
} elseif(isset($_POST['qanswer']) && $_POST['qanswer'] == "TheRealAnswer") {
$_SESSION['answered'] = 1;
//Display page