bylletski Posted March 16, 2013 Share Posted March 16, 2013 (edited) 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? Edited March 17, 2013 by ignace Added code tags Quote 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) Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.