Created
September 18, 2015 15:16
-
-
Save jkuip/75c041c1ce539ede24dc to your computer and use it in GitHub Desktop.
Simple PHP question
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Question</title> | |
<meta charset="utf-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet"> | |
</head> | |
<body> | |
<div class="container" style="margin-top: 50px"> | |
<?php | |
// If the submit button has been pressed | |
if(isset($_POST['submit'])) | |
{ | |
// Check answer | |
if($_POST['answer'] == '42') | |
{ | |
echo "<div class=\"alert alert-success\">That is correct.</div>"; | |
} else { | |
echo "<div class=\"alert alert-danger\">That is incorrect.</div>"; | |
} | |
} | |
?> | |
<!-- Quiz Form --> | |
<form method="post" action="question.php"> | |
<div class="form-group"> | |
<label>what is the answer to life the universe and everything?</label> | |
<input name="answer" type="text" class="form-control" /> | |
</div> | |
<input name="submit" type="submit" value="Check answer" class="btn btn-primary" /> | |
</form> | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment