galvin Posted January 11, 2011 Share Posted January 11, 2011 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! Quote Link to comment https://forums.phpfreaks.com/topic/224115-general-advice-on-plan-of-attach-for-quiz-website/ Share on other sites More sharing options...
jdavidbakr Posted January 12, 2011 Share Posted January 12, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/224115-general-advice-on-plan-of-attach-for-quiz-website/#findComment-1158538 Share on other sites More sharing options...
ignace Posted January 13, 2011 Share Posted January 13, 2011 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). Quote Link to comment https://forums.phpfreaks.com/topic/224115-general-advice-on-plan-of-attach-for-quiz-website/#findComment-1158876 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.