Jump to content

Recommended Posts

I'm going to be creating a site similar to sporcle, where users take tests.

 

The tests would work like this...

 

There is a single entry field where users enter their guesses to a list of questions (listed below the field in a table).  In the table, there is a hidden answer field next to each corresponding question and when a user entered answer matches one of the hidden answer fields, the hidden answer is revealed.

 

Just looking for people's thoughts on the best/most efficient way to do this when it comes to PHP vs. Javascript vs. AJAX, keeping in mind the possibility of having thousands of tests one day, with thousands of daily visitors.

 

I think I HAVE to use at least some Javascript (or AJAX) in order to make a hidden answer get revealed WITHOUT having to reload the page.  In other words, that is not possible with PHP only, right?

 

My main confusion is that for most of the things I want to do, I can probably use either Javascript or PHP.  But if I'm fortunate enough to get to the point where thousands of users are using my site, wouldn't it be better if more stuff was done in Javascript so that the server isn't being taxed by PHP code?  Or am I not thinking about that correctly?

 

Any feedback/advice would be appreciated.

 

Thanks!

Javascript pushes the application logic to the client browser, so that would reduce the server load; but if you want to prevent the answer from even being on the client's computer (where they can look at the source to find the answer) you would have to do it with ajax and ping your server.

 

However, that kind of request is not going to tax your server much; you'll just be sending back probably JSON or even just the text of the answer.  And you're going to have to query the database either way to get the answer.

 

Your web server is designed to handle tons of requests, remember each image/stylesheet/etc on your page is a separate request.  The server load for pinging back to the server to get the answer won't be significant compared to the server load to get the question in the first place.

If you are hiding the correct possible answers in your HTML then everyone with some HTML knowledge will be able to answer your questions correctly. Let the user enter the answer match that in PHP with the correct possible answers synchronously (reload the page) or asynchronously (AJAX, reload part of a page).

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.