validate check?

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
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.

$FAIL = "surveyfailed.php";
$FAIL2 = "surveyfailed2.php";
$TRY = "surveyq.php";

$id = $_POST['id'];
$class = $_POST['course'];

$sql = "SELECT * FROM $db_table10 WHERE id = '$id'";
$result = mysql_query ($sql, $connect) or die('Query 4 failed: ' .
$num = mysql_num_rows($result);

if ($num == 0)
echo "<meta http-equiv='Refresh' content='1;url=$FAIL'>";
$passid = $id;
$passcid = $class;
$_SESSION['passid'] = $passid;
$_SESSION['passcid'] = $passcid;
echo "<meta http-equiv='Refresh' content='1;url=$TRY'>";

Re: validate check?



Quoted text here. Click to load it

$id = isset($_POST['id']) ? mysql_real_escape_string($_POST['id']) : '=

Quoted text here. Click to load it

$sql = "SELECT classid FROM $db_table10 WHERE id = '$id'"

Quoted text here. Click to load it

Don't die() with an internal error (mysql_error()) in production, provid=
e  =

a nice 'something went wrong and we're sorry'-page.

Quoted text here. Click to load it

header() redirects are more reliable & better overall.
header('Location: http://'.$_SERVER['HTTP_HOST'].'/'.$FAIL);

Quoted text here. Click to load it

$row = mysql_fetch_assoc($result);
    header('Location: http://'.$_SERVER['HTTP_HOST'].'/'.$FAIL2);
} else {
    $_SESSION['passid'] = $id;
    $_SESSION['passcid'] = $class;
    header('Location: http://'.$_SERVER['HTTP_HOST'].'/'.$TRY);

Quoted text here. Click to load it

-- =

Rik Wasmus
[SPAM] Now temporarily looking for some smaller PHP/MySQL projects/work =
to  =

fund a self developed bigger project, mail me at rik at [/SP=

Site Timeline