Skip to content

Instantly share code, notes, and snippets.

@alexanderjsingleton
Last active March 14, 2016 14:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexanderjsingleton/7b3f0073287d3675169f to your computer and use it in GitHub Desktop.
Save alexanderjsingleton/7b3f0073287d3675169f to your computer and use it in GitHub Desktop.
Learn php the Hard Way.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<meta name="description" content="">
<meta name="author" content="">
<link rel="icon" href="BucephalusDev-Favicon.png">
<title>Sticky Footer Navbar Template for Bootstrap</title>
<!-- Bootstrap core CSS -->
<link href="bootstrap-3.3.6/dist/css/bootstrap.min.css" rel="stylesheet">
<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
<link href="bootstrap-3.3.6/docs/assets/css/ie10-viewport-bug-workaround.css" rel="stylesheet">
<!-- Custom styles for this template -->
<link href="sticky-footer-navbar.css" rel="stylesheet">
<!-- Just for debugging purposes. Don't actually copy these 2 lines! -->
<!--[if lt IE 9]><script src="../../assets/js/ie8-responsive-file-warning.js"></script><![endif]-->
<script src="bootstrap-3.3.6/docs/assets/js/ie-emulation-modes-warning.js"></script>
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<!-- Fixed navbar -->
<nav class="navbar navbar-default navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="logo" rel="home" href="#" title="The George Washington University">
<img src="gwu.png">
</a>
</div>
<div id="navbar" class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li><a href="index.html">Home</a></li>
<li><a href="register.html">Register</a></li>
<li><a href="members.html">Members</a></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Dropdown <span class="caret"></span></a>
<ul class="dropdown-menu">
<li class="active"><a href="standard-form.html">Standard Form Validation</a></li>
<li><a href="#">Coming Soon?</a></li>
<li role="separator" class="divider"></li>
<li class="dropdown-header">Would you like to know more?</li>
<li><a href="#">Ready Player One</a></li>
</ul>
</li>
</ul>
</div><!--/.nav-collapse -->
</div>
</nav>
<?php
$nameErr = $emailErr = $phoneErr = $addressErr = $cityErr = $stateErr = $zip_codeErr = $websiteErr = $hostingErr = $projectErr = "";
$name = $email = $phone = $address = $city = $state = $zip_code = $website = $hosting = $project = "";
if ($_SERVER["REQUEST_METHOD"] == "POST") {
if (empty($_POST["first_name"])) {
$first_nameErr = "first_name is required";
} else {
$first_name = test_input($_POST["first_name"]);
// check if first_name only contains letters and whitespace
if (!preg_match("/^[a-zA-Z ]*$/",$first_name)) {
$first_nameErr = "Only letters and white space allowed";
}
}
if (empty($_POST["last_name"])) {
$last_nameErr = "last_name is required";
} else {
$last_name = test_input($_POST["last_name"]);
// check if last_name only contains letters and whitespace
if (!preg_match("/^[a-zA-Z ]*$/",$last_name)) {
$last_nameErr = "Only letters and white space allowed";
}
}
if (empty($_POST["email"])) {
$emailErr = "Email is required";
} else {
$email = test_input($_POST["email"]);
// check if e-mail address is well-formed
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
$emailErr = "Invalid email format";
}
}
if (empty($_POST["phone"])) {
$phoneErr = "phone is required";
} else {
$phone = test_input($_POST["phone"]);
// check if phone only contains letters and whitespace
if (!preg_match("/^[a-zA-Z ]*$/",$phone)) {
$phoneErr = "Only letters and white space allowed";
}
}
if (empty($_POST["address"])) {
$addressErr = "address is required";
} else {
$address = test_input($_POST["address"]);
// check if address only contains letters and whitespace
if (!preg_match("/^[a-zA-Z ]*$/",$address)) {
$addressErr = "Only letters and white space allowed";
}
}
if (empty($_POST["city"])) {
$cityErr = "city is required";
} else {
$city = test_input($_POST["city"]);
// check if city only contains letters and whitespace
if (!preg_match("/^[a-zA-Z ]*$/",$city)) {
$cityErr = "Only letters and white space allowed";
}
}
if (empty($_POST["state"])) {
$stateErr = "state is required";
} else {
$state = test_input($_POST["state"]);
// check if state only contains letters and whitespace
if (!preg_match("/^[a-zA-Z ]*$/",$state)) {
$stateErr = "Only letters and white space allowed";
}
}
if (empty($_POST["zip_code"])) {
$zip_codeErr = "zip_code is required";
} else {
$zip_code = test_input($_POST["zip_code"]);
// check if zip_code only contains letters and whitespace
if (!preg_match("/^[a-zA-Z ]*$/",$zip_code)) {
$zip_codeErr = "Only letters and white space allowed";
}
}
if (empty($_POST["website"])) {
$website = "";
} else {
$website = test_input($_POST["website"]);
// check if URL address syntax is valid (this regular expression also allows dashes in the URL)
if (!preg_match("/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i",$website)) {
$websiteErr = "Invalid URL";
}
}
if (empty($_POST["hosting"])) {
$hostingErr = "hosting is required";
} else {
$hosting = test_input($_POST["hosting"]);
// check if hosting only contains letters and whitespace
if (!preg_match("/^[a-zA-Z ]*$/",$hosting)) {
$hostingErr = "Only letters and white space allowed";
}
}
if (empty($_POST["project"])) {
$projectErr = "project is required";
} else {
$project = test_input($_POST["project"]);
// check if project only contains letters and whitespace
if (!preg_match("/^[a-zA-Z ]*$/",$project)) {
$projectErr = "Only letters and white space allowed";
}
}
}
function test_input($data) {
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
?>
<!-- Begin page content -->
<div class="container">
<div class="page-header">
<h1>Registration</h1>
</div>
<p class="lead">If you would like to request membership to GWMSIST_ISTM_6205 Project I, please populate the below form to apply for verification.</p>
<p>As stated within the <a href="register.html">Registration</a> page of this production, this is the registraion form using conventional JavaScript instead of the BootStrap framework validation technique, complementarily included <a href="https://gist.githubusercontent.com/alexanderjsingleton/8a710216c7ebd38a03eb/raw/006985d91d7d5fa66a3e8bec326d14230d7307c9/standard-validation.js">via Secret GitHub Gist</a> (not available to public unless shared) beneath the submit button in the below form.</p>
</div>
<div class="container">
<div class="container">
<p><span class="error">* required field.</span></p>
<form name='mainForm' id='mainForm' method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
<fieldset>
<legend>Required Information:</legend>
<div class="form-group">
<label for= "first_name" class="control-label col-sm-4">First Name:</label>
<input name="first_name" id="first_name" type="text" value="<?php echo $name;?>" size="30" class="required">
<span class="error">* <?php echo $nameErr;?></span>
</div>
<div class="form-group">
<label for= "last_name" class="control-label col-sm-4">Last Name:</label>
<input name="last_name" id="last_name" type="text" size="30" class="required" value="<?php echo $last_name;?>">
<span class="error">* <?php echo $last_nameErr;?></span>
</div>
<div class="form-group">
<label for= "email" class="control-label col-sm-4">E-mail:</label>
<input name="email" id="email" type="text" size="30" class="required" value="<?php echo $email;?>">
<span class="error">* <?php echo $emailErr;?></span>
</div>
<div class="form-group">
<label for= "phone" class="control-label col-sm-4">Phone #:</label>
<input name="phone" id="phone" type="text" size="30" class="required" value="<?php echo $phone;?>">
<span class="error">* <?php echo $phoneErr;?></span>
</div>
<div class="form-group">
<label for= "address" class="control-label col-sm-4">Address:</label>
<input name="address" id="address" type="text" size="30" class="required" value="<?php echo $address;?>">
<span class="error">* <?php echo $addressErr;?></span>
</div>
<div class="form-group">
<label for= "city" class="control-label col-sm-4">City:</label>
<input name="city" id="city" type="text" size="30" class="required" value="<?php echo $city;?>">
<span class="error">* <?php echo $cityErr;?></span>
</div>
<div class="form-group">
<label for= "state" class="control-label col-sm-4">State:</label>
<input name="state" id="state" type="text" size="30" class="required" value="<?php echo $state;?>">
<span class="error">* <?php echo $stateErr;?></span>
</div>
<div class="form-group">
<label for= "zip_code" class="control-label col-sm-4">Zip Code:</label>
<input name="zip_code" id="zip_code" type="text" size="30" class="required" value="<?php echo $zip_code;?>">
<span class="error">* <?php echo $zip_codeErr;?></span>
</div>
<div class="form-group">
<label for= "website" class="control-label col-sm-4">Website or Domain:</label>
<input name="website" id="website" type="text" size="30" class="required" value="<?php echo $website;?>">
<span class="error">* <?php echo $websiteErr;?></span>
</div>
<div class="form-group">
<label for= "hosting" class="control-label col-sm-4">Do you have hosting?</label>
<input name="hosting" id="hosting" type="text" size="30" class="required" value="<?php echo $hosting;?>">
<span class="error">* <?php echo $hostingErr;?></span>
</div>
<div class="form-group">
<label for= "project" class="control-label col-sm-4">Project Description:</label>
<input name="project" id="project" type="text" size="30" class="required" value="<?php echo $project;?>">
<span class="error">* <?php echo $projectErr;?></span>
</div>
</fieldset>
<fieldset>
<legend>Optional Information:</legend>
<div class='movingDiv'>
<label for="how" class="col-md-4 control-label">How did you hear about us?</label>
<input name="how" id="how" type="text" size="30">
</div>
</fieldset><br>
<button type="submit" class="btn btn-primary">Submit</button>
</form>
<?php
echo "<h2>Your Input:</h2>";
echo $name;
echo "<br>";
echo $email;
echo "<br>";
echo $phone;
echo "<br>";
echo $website;
echo "<br>";
echo $address;
echo "<br>";
echo $city;
echo "<br>";
echo $state;
echo "<br>";
echo $zip_code;
echo "<br>";
echo $website;
echo "<br>";
echo $hosting;
echo "<br>";
echo $project;
echo "<br>";
?>
</div>
</div>
<footer class="footer">
<div class="container">
<div id="navbar" class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li class="active"><a href="index.html">Home</a></li>
<li><a href="about.html">About</a></li>
<li><a href="contact_us.html">Contact</a></li>
</li>
</ul>
</div><!--/.nav-collapse -->
</div>
</nav>
</footer>
<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="../../assets/js/vendor/jquery.min.js"><\/script>')</script>
<script src="bootstrap-3.3.6/dist/js/bootstrap.min.js"></script>
<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
<script src="bootstrap-3.3.6/docs/assets/js/ie10-viewport-bug-workaround.js"></script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment