The echo statement is not printing when the answer does not equal to 8.So if the answer is other than 8 it should print in red "Please try again " underneath the textbox.All it shows is nothing when I click the register button.
<?php
session_start();
$nameErr = "";
$answer = $_POST['lastname'];
if ($_POST['reg']){
if ($answer != '8') {
echo "<span style='color:red'>Please enter Correct Answer</span>";
}
}
?>
<!Doctype html>
<head>
<link href="bootstrap/css/bootstrap.min.css" rel="stylesheet"
type="text/css">
<link href="bootstrap/css/styles.css" rel="stylesheet" type="text/css">
<link rel="stylesheet" type="text/css" href="Register.css">
<script src='https://www.google.com/recaptcha/api.js'></script>
<title> Register</title>
</head>
<html>
<body>
<form method="post" action="">
What is 5 + 3 =<br>
<input type="text" name="lastname">
<div class="row">
<div class="form-group col-xs-5 col-xs-offset-3.5">
<input class="btn btn-primary btn-lg btn-block" value="Register"
type="submit" name="reg">