Skip to content

Instantly share code, notes, and snippets.

@websmith
Last active July 4, 2016 15:45
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 websmith/d61cb17e72ee3a7a20188470fee6d34e to your computer and use it in GitHub Desktop.
Save websmith/d61cb17e72ee3a7a20188470fee6d34e to your computer and use it in GitHub Desktop.
<?php
if(isset($_POST['submit'])) {
// Save the values of all of our form data as variables
$username = $_POST['username'];
$email = $_POST['email'];
$message = $_POST['message'];
//Validate $username
if(!isset($username) || empty($username)) {
echo "<p>Please fill out your user name.</p>";
}
else {
echo "<p>Username: ".$username."</p>";
}
//Validate $email
if(!isset($email) || empty($email)) {
echo "<p>Please fill out your email.</p>";
}
else {
echo "<p>Email: ".$email."</p>";
}
//Validate $message
if(!isset($message) || empty($message)) {
echo "<p>Please fill out the message field.</p>";
}
else {
echo "<p>Message: ".$message."</p>";
}
} else {
echo "<p>The form was not submitted!</p>";
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment