samedi 28 mars 2015

Comparing a value inside database with input value

My if statement doesn't recognize the textbox name ("ans"). What should I change? and where should I put it? I also want to know if my if statement is correct; I want to compare the value inside the database with the input value ("ans"). Thanks in advance.



<?php
$con = mysql_connect("localhost", "root", "avtt123");
mysql_select_db("arvintarrega",$con);

$sql3 = "SELECT * from enumeration";
$myData3 = mysql_query($sql3,$con);

echo '<form method = "POST">';

while($iden = mysql_fetch_array($myData))
{
echo '<center>' . $iden['question_number'] . '. ' . $iden['statement'] . ' <input type = "text" name = "ans"></input></center></br>';

if($iden['correct_answer'] == $_REQUEST['ans'])
{
echo "Correct";
}
else
{
echo "Wrong";
}
}
echo '</form>';
?>

Aucun commentaire:

Enregistrer un commentaire