Sample PHP Form
<!doctype="html">
<html lang="en-us">
<head>
<meta charset="UTF-8">
<title>Form Template</title>
<meta name="application-name" content="notepad++">
<meta name="author" content="Jim Gerland">
</head>
<body>
<div id="main">
<h1>Form Template</h1>
<?php
$action = $_POST['action'];
if ($action = "Submit") {
$firstName = filter_input(INPUT_POST, 'firstName');
$lastName = filter_input(INPUT_POST, 'lastName');
if (empty($firstName)) {
$firstName = "<br><span style=\"color: red; font-weight: bold;\">First Name must be provided</span><br>";
}
if (empty($lastName)) {
$lastName = "<br><span style=\"color: red; font-weight: bold;\">Last Name must be provided</span>";
}
}
$echo("<p>Welcome $firstName $lastName!</p>");
?>
<form id="myForm" name="myForm" method="POST" action="sample_form.php">
<label for="firstName">First Name:</label>
<input id="firstName" name="firstName"><br style="clear: both;>
<label for="lastName">Last Name:</label>
<input id="lastName" name="lastName"><br style="clear: both;>
<input type="submit" id="action" name="action" value="Submit">
<input type="reset" id="reset" name="reset">
</form>
</div> <!-- end id="main" -->
</body>
</html>
Form Template