Guest User

Untitled

a guest
Feb 28th, 2018
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.92 KB | None | 0 0
  1. <?php
  2.     require_once('mysql.class.php');
  3.    
  4.     //  CHANGE THESE TO VALID FOR YOUR
  5.     //  MYSQL CONNECTION DETAILS
  6.     $host = 'localhost';
  7.     $user = 'db_user';
  8.     $pass = 'password';
  9.     $db = 'db_name';
  10.     //  CHANGE THESE TO VALID FOR YOUR
  11.     //  MYSQL CONNECTION DETAILS
  12.  
  13.     $redirect_unique = 'redir_a.htm';   //  Site to redirect to when the zip-code is not present in the db
  14.     $redirect_exists = 'redir_b.htm';   //  Site to redirect to when the zip-code is present in the db
  15.    
  16.     if (isset($_POST['zipcode'])) {
  17.         $zip = $_POST['zipcode'];
  18.        
  19.         $conn_params = array (
  20.             'host' => $host,
  21.             'user' => $user,
  22.             'pass' => $pass,
  23.             'db' => $db
  24.         );
  25.         $conn = new mysql($conn_params);
  26.        
  27.         $result = $conn->select(array('table' => 'zipcodes', 'condition' => 'zipcode = "'.$zip.'"', 'limit' => 1));
  28.         if (count($result) == 0) {
  29.             // that record was not found do something here
  30.         }
  31.             header('Location: '.$redirect_exists);
  32.             die();
  33.     }
  34. ?>
Add Comment
Please, Sign In to add comment