bylletski Posted March 16, 2013 Share Posted March 16, 2013 Hello I'm new in this forum but i hope you understand what I trying to do. <?php $theanswer = 4; $answer = $_POST['answer']; if(isset($_POST['button'])){ if ($theanswer = $answer){ echo "Right the answer is 4<br>"; } else { echo "Wrong try again!"; } } ?> 2 + 2 is? <form method="post" action="new.php"> <input type="text" name="answer"> <input type="submit" name="button"> </form> The code don't work and I get an notice too. Notice: Undefined index: answer in C:\wamp\www\ss\new.php on line 4 I think you understand what i want but i will explain if you don't. If they write 4 in the textfield the echo will say Right the answer is 4. But if they write anything else it will say wrong try again! Now i wonder what have i do wrong? Link to comment https://forums.phpfreaks.com/topic/275751-try-to-make-a-question-with-variabels/ Share on other sites More sharing options...
bylletski Posted March 16, 2013 Author Share Posted March 16, 2013 Nevermind i figure it out. Before ($theanswer = $answer) Now ($theanswer == $answer) Link to comment https://forums.phpfreaks.com/topic/275751-try-to-make-a-question-with-variabels/#findComment-1419060 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.