I want to make toefl test. I make table score_structure in database containing 4 columns (email, right, false, score). If the user has done on previous test and will perform a test again, then the user data will be updated according to the user's email pitch.
I have tried but failed, the data will not update. Please help me.
This is structure.php
<?php
$email = $_SESSION['email'];
$cek = mysql_num_rows(mysql_query("SELECT email FROM score_structure WHERE email='$email'"));
if($cek > 0 ) {
$simpan = "UPDATE score_structure SET right='$right', false='$false', score='$score' WHERE email='$email'";
if(mysql_query($simpan)) {
header("location:test_listening.php");
} else {
echo mysql_error();
} else {
$simpan = "INSERT INTO score_structure VALUES ('$email', '$right', '$false', '$score')";
if(mysql_query($simpan)) {
header("location:test_listening.php");
} else {
echo mysql_error();
}
}
?>