<?php
// This is the PHP code that will process the form data.
// Connect to the database.
$mysqli = new mysqli("192.168.214.101", "sguwpsites625$%$", "ylL3txCFQJm62015", "zipcodes");
// Check if the connection was successful.
if ($mysqli->connect_error) {
die("Error connecting to the database: " . $mysqli->connect_error);
}
// Get the form data.
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$email = $_POST['email'];
$zipcode = $_POST['zip_code'];
$division = $_POST['division_code'];
// Check if the form was submitted correctly.
if (isset($_POST['submit'])) {
// Check if the zip code and division code are valid.
if (empty($zip_code) || empty($division_code)) {
// The zip code or division code is empty.
echo 'Please enter a valid zip code and division code.';
} else {
// The zip code and division code are valid.
// Check if the zip code exists in the database.
$sql = "SELECT * FROM zipcodes WHERE zip_code = '$zip_code'";
$result = $mysqli->query($sql);
// Check if the query was successful.
if ($result) {
// The query was successful.
if ($result->num_rows > 0) {
// The zip code exists in the database.
echo "The zip code $zip_code exists in the database.";
} else {
// The zip code does not exist in the database.
echo "The zip code $zip_code does not exist in the database.";
}
} else {
// The query was not successful.
echo "Error querying the database: " . $mysqli->error;
}
}
}
// Close the connection to the database.
$mysqli->close();
?>