Hello everyone,
I wondered if someone could help, as this is majorly stressing me out!
I have a PHP quiz, that when completed sends the score and session username to the table quiz.
I want to be able to only allow them to complete the quiz once. So IF the session username is already in the quiz table echo 'you can only do the quiz once' else echo 'you have 1 quiz to be taken'
If anyone could help, i would massively appreciate it!
Thanks
Page 1 of 1
Small PHP Help
#2
Posted 17 March 2010 - 07:25 AM
change to suit you but something like :
$user_name = $_SESSION["username"];
$query = "SELECT quizdone from users WHERE username = $user_name limit 0,1";
$result = mysql_query($query) or die('Query failed: ' . mysql_error()); unset($query);// fetch result set and free resources
if (!$result){
echo "sorry there was an error"; // simple error checking
exit; // if error then stop form
}
else
{
$row = mysql_fetch_row($result) unset($result); //fetch single row and free resources
if($row[0] === "true") //check if quizdone is true
{
echo "you have done this before";
}
}
#3
Posted 17 March 2010 - 09:51 AM
You could also set a cookie, store the visitors IP in your table - not definate ways to determine if someone has taken the quiz, but enought to put people off.
- ← What is the significance of storage engine in phpmyadmin
- Server Side (PHP, Databases, ASP.NET, etc)
- Reducing database usage →
Share this topic:
Page 1 of 1
Help
















