Currently, it checks to see if id is in db. If it is, it takes the
user to the survey. If not it takes the user to a page to try re-
entering code. I want to add another option. I want it to check and
see if the classid field in the db is empty if it is not empty, I want
it to go to a page saying survey has already been taken. How do I do
this? I tried a compunf if statement but it didn't work.
<?PHP
$FAIL = "surveyfailed.php";
$FAIL2 = "surveyfailed2.php";
$TRY = "surveyq.php";
if(isset($_POST['entersurvey']))
{
$id = $_POST['id'];
$class = $_POST['course'];
$sql = "SELECT * FROM $db_table10 WHERE id = '$id'";
$result = mysql_query ($sql, $connect) or die('Query 4 failed: ' .
mysql_error());
$num = mysql_num_rows($result);
if ($num == 0)
{
echo "<meta http-equiv='Refresh' content='1;url=$FAIL'>";
}
else
{
$passid = $id;
$passcid = $class;
$_SESSION['passid'] = $passid;
$_SESSION['passcid'] = $passcid;
echo "<meta http-equiv='Refresh' content='1;url=$TRY'>";
}
}
?>