function fwr ($q) { $msg=$q . "\r\n"; $filename = "pitanja.txt"; $f = fopen($filename, 'a'); fwrite($f, $msg, strlen($msg)); fclose($f); } //------------- if (isset($_GET['question'])) { $ima=0; if (empty($_GET['question'])) { echo "

You should write a question. That's for sure

"; echo "
Huh?!!
\"\"
"; echo "Try again"; } else { echo "

Should I ...

"; $q = strip_tags($_GET['question']); $prc = rtrim($q,'?'); echo "$prc?"; $i = $_SESSION['count']; for ($z=1; $z <= $i; $z++) { if ($prc == $_SESSION['question'][$z]) { $ima = "1"; $answ = $_SESSION['answer'][$z]; } } if ($ima == "1") { echo "
".$answ."
\"\"
Type another question"; }else { $i = $_SESSION['count']; $r=mt_rand(0,100000); if ($r>50000) $answer= "Yes"; else $answer="No"; $_SESSION['question'][$i] = $prc; $_SESSION['answer'][$i] = $answer; $_SESSION['count']++; echo "
".$answer."
\"\"
Type another question"; fwr($q); } } }