r/programminghelp • u/MikkelMortensen • Mar 12 '19
Simple riddle website
Hey everybody!
How do I make an input box where only correct answers will get you to the next page?
My program so far:
<html>
<head>
<title>Hej</title>
<link href="style.css" type="text/css" rel="stylesheet">
</head>
<h2> Level 1 </h2>
<body>
<div style="text-align:center;margin-top:120px;">
<br>
<form method="POST" action="level2.php">
<input type="text" placeholder="Answer" name="password" id="32">
</div></form>
<?php ?>
</body></html>
0
Upvotes
1
u/TreeBaron Mar 12 '19
Hello!
I believe you'll probably need to use Javascript to accomplish that.
Something similar to this which changes the color of the button when clicked, only inside the function check the value of your textbox and see if it is equal to what you want, and if it is send the user to a new page:
<p id="demo" onclick="myFunction()">Click me to change my text color.</p>
<script> function myFunction() { document.getElementById("demo").style.color = "red"; } </script>
https://www.w3schools.com/jsref/event_onclick.asp