I'm new to PHP so bear with me.
This is part of some php that checks if an entered "code" is valid, then it sends additional info to a sql database.
I want to check field2 and if the value is "valueB" then goto a different web page. Here's the section of PHP with that "if" statement(line 28). it's not working for me
---------------------------------------------------------------
[PHP]global $ValidateMessage;
$code = $_REQUEST['code'];
if (strlen($code) == 0)
{
$ValidateMessage="";
}
else if (Code_DecodeCode($code) === TRUE)
{
global $gCms;
$db =& $gCms->GetDb();
$code = $db->qstr($_REQUEST['code']);
$field1 = $db->qstr($_REQUEST['field1']);
$field2 = $db->qstr($_REQUEST['field2']);
$field3 = $db->qstr($_REQUEST['field3']);
$sql = "INSERT INTO table SET code=$code, field1=$field1, field2=$field2, field3=$field3;
$db->query($sql);
if (@mysql_affected_rows() == 1)
{
if($field2 == "valueB") {
header("Location: http://www.******");
exit;
} else {
header("Location: http://www.******");
exit;
$ValidateMessage = "Code accepted.";
}
}
else
$ValidateMessage = "$code has already been submitted";
}
else
{
$ValidateMessage = "$code is not valid";
}
echo "$ValidateMessage";[/PHP]