Created
July 1, 2012 17:28
-
-
Save sethkrasnianski/3029029 to your computer and use it in GitHub Desktop.
PHP State Form Validation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
TITLE: PHP State Form Validation | |
AUTHOR: Seth Krasnianski | |
PURPOSE: Validates that HTML form input are set, and abide by rules of state expungement laws. | |
*/ | |
$default = 'State'; // Default for state select input | |
$default_conv = 'Select One'; // Default for conviction input | |
// State array for matching with state select | |
$stateList = Array('Arizona', 'California', 'Connecticut', 'Florida', 'Illinois', 'Michigan', 'Minnesota', 'Nevada', 'New Hampshire', 'New Jersey', 'New York', 'Ohio', 'Pennsylvania', 'Rhode Island', 'Texas', 'Utah', 'Washington'); | |
$state = $_POST['state']; // Sets state variable | |
$conviction = $_POST['conviction']; // Sets conviction variable | |
// Sends state form again if state is default choice | |
if ((!isset($state) || ($state == $default))) { | |
include ('stateselect.inc.php'); | |
// Sends next form to validate convictions | |
} else { | |
// Checks if valid conviction is chosen | |
if ((isset($conviction)) && ($conviction != $default_conv)) { | |
// If conviction is "Diversion / Deferred" user is not eligible | |
if($_POST['conviction'] == "diversionDeferred" ) { | |
include ('../header.php'); | |
echo "Not Eligible: We are sorry, but you are not eligible at this time."; | |
include('../sidebar.php'); | |
// If conviction is set to anything but "Diversion / Deffered" or default, display coresponding questions based on conviction | |
} else { | |
// include generates appropriate questions | |
include('stateform.inc.php'); | |
} | |
// Case select was not applicable, choose again | |
} else { | |
include('caseSelect.inc.php'); | |
} | |
} | |
?> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment