Skip to content

Instantly share code, notes, and snippets.

@jkuip
Created September 18, 2015 15:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jkuip/75c041c1ce539ede24dc to your computer and use it in GitHub Desktop.
Save jkuip/75c041c1ce539ede24dc to your computer and use it in GitHub Desktop.
Simple PHP question
<!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