PHP header redirect in else statement not working..

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Jpizzolato
    New Member
    • Feb 2015
    • 8

    PHP header redirect in else statement not working..

    Code:
    <?php
    $host="localhost";
    $base="mydb";  
    $user="myusername";
    $pass="mypassword"; 
     
    $connect=mysql_connect($host, $user, $pass) or die("Could not connect to database!!!!");
    mysql_select_db($base,$connect) or die("Count not find database table!");
     
    if(isset($_POST['zip'])){
        $zip=htmlspecialchars(mysql_real_escape_string($_POST['zip']));
        $res=mysql_fetch_assoc(mysql_query("SELECT url FROM url_db WHERE zip='$zip'"));
        header('Location: '.$res['url']);
        exit;
    }
     
    else{ 
        header('Location: http://www.bettercabletv.com/not-listed.html');
    }
    ?>
    When I go to the site http://www.bettercable tv.com and type in 12345 as a zip it directs me to the process.php and a blank screen. Any idea whats going on?
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    Does the zip 12345 exist in your database? And does it have a valid url in the field?

    Comment

    Working...