This is my first php program. Im trying to compare the result of adding two randomly generated numbers (visually displayed before text field) to the answer i give in the submit. But it just wont work. I pass the result at $value3 and try to compare it to the result of the submit. Any ideas guys?
<head>
<title>
</title>
</head>
<?php
$displayForm=True;
if(isset($_GET['result'])){
$displayForm=False;
}
if($displayForm){
?>
<body>
<form method="GET">
result
<?php
$value1=rand(1,10);
$value2=rand(1,10);
$value3=$value1 + $value2;
echo($value1);
echo("+");
echo($value2);
?>
<input type="text" name="number">
<input type="hidden" name="val3" value="$value3">
<input type="submit" name="result" value="submit">
</form>
<?php
}
if(isset($_GET['result'])){
if(isset($_GET['result'])){
$result = $_GET['result'];
}
if($result==$_GET['val3']){
echo "result right: you re human";
}
else{
echo "lol you are a retarded cat";
}
}
?>
</body>