Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require_once('mysql.class.php');
- // CHANGE THESE TO VALID FOR YOUR
- // MYSQL CONNECTION DETAILS
- $host = 'localhost';
- $user = 'db_user';
- $pass = 'password';
- $db = 'db_name';
- // CHANGE THESE TO VALID FOR YOUR
- // MYSQL CONNECTION DETAILS
- $redirect_unique = 'redir_a.htm'; // Site to redirect to when the zip-code is not present in the db
- $redirect_exists = 'redir_b.htm'; // Site to redirect to when the zip-code is present in the db
- if (isset($_POST['zipcode'])) {
- $zip = $_POST['zipcode'];
- $conn_params = array (
- 'host' => $host,
- 'user' => $user,
- 'pass' => $pass,
- 'db' => $db
- );
- $conn = new mysql($conn_params);
- $result = $conn->select(array('table' => 'zipcodes', 'condition' => 'zipcode = "'.$zip.'"', 'limit' => 1));
- if (count($result) == 0) {
- // that record was not found do something here
- }
- header('Location: '.$redirect_exists);
- die();
- }
- ?>
Add Comment
Please, Sign In to add comment