view source causing problems

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
fredley
Forum Newbie
Posts: 7
Joined: Thu Oct 25, 2007 5:32 am

view source causing problems

Post by fredley »

I have made a test program, with a check to ensure people can't get 90% of the way through, and then refresh knowing all the answers and start again.

At the start of my page is a check for a posted variable (from the previous page where options for the test are submitted). If this variable isn't posted, the page redirects. Once all the checks have been passed, the script inserts a row into my database with score=0 and a unique test id. A test is then taken in a flash file embedded on that page, to which the appropriate variables have been passed. At the end of the test the flash file updates the row in the database by calling on another php file (with more checks to ensure it is the flash file calling it). However, if I view the source of the page, all the checks are bypassed and a new row is inserted every time I do this. Is there any way for php to check if the source of a page is being viewed?
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Post by Kieran Huggins »

nope - the browser doesn't send that info to the server.
fredley
Forum Newbie
Posts: 7
Joined: Thu Oct 25, 2007 5:32 am

Post by fredley »

Any other kind of work-around you can think of? This one's got me stumped.
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Post by Kieran Huggins »

You could track the questions in a session. That way you know which ones have been answered already.

Saving them to the database as they're answered (and tying them to the user) prevents them from taking the test again.
Post Reply