Passing url variable not working for me....help

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

    Passing url variable not working for me....help

    Code:
    <?php
    $base="db";  
    
    $connect=mysql_connect('localhost','username','password') 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 redirect WHERE zip='$zip'"));
    	header('Location: '.$res['url']);
    	exit;
    }
    
    else{ 
    	header('Location: http://www.mywebsite.com/not-listed.html');
    }
    ?>
    I've got three columns in my database id zip and url. Each time I run the script in search it automatically redirects me to the else location.
    Last edited by Rabbit; Feb 4 '15, 05:59 AM. Reason: Please use [code] and [/code] tags when posting code or formatted data.
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    Please use code tags when posting code or formatted data.

    That means your post array doesn't have a key named zip.

    Comment

    • Jpizzolato
      New Member
      • Feb 2015
      • 8

      #3
      Can you give me an example?

      Comment

      • Jpizzolato
        New Member
        • Feb 2015
        • 8

        #4
        Ahhh you know what you're absolutely right. I named it zipcode in the array.... Stupid of me thanks

        Comment

        • Rabbit
          Recognized Expert MVP
          • Jan 2007
          • 12517

          #5
          No problem, everyone makes these mistakes

          Comment

          • Jpizzolato
            New Member
            • Feb 2015
            • 8

            #6
            Can you check my other post? I'm still having issues.

            Comment

            Working...