423,309 Members | 2,163 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 423,309 IT Pros & Developers. It's quick & easy.

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

P: 8
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. $base="db";  
  3.  
  4. $connect=mysql_connect('localhost','username','password') or die("Could not connect to database!!!!");
  5. mysql_select_db($base,$connect) or die("Count not find database table!");
  6.  
  7. if(isset($_POST['zip'])){
  8.     $zip=htmlspecialchars(mysql_real_escape_string($_POST['zip']));
  9.     $res=mysql_fetch_assoc(mysql_query("SELECT url FROM redirect WHERE zip='$zip'"));
  10.     header('Location: '.$res['url']);
  11.     exit;
  12. }
  13.  
  14. else{ 
  15.     header('Location: http://www.mywebsite.com/not-listed.html');
  16. }
  17. ?>
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.
Feb 4 '15 #1
Share this Question
Share on Google+
5 Replies


Rabbit
Expert Mod 10K+
P: 12,247
Please use code tags when posting code or formatted data.

That means your post array doesn't have a key named zip.
Feb 4 '15 #2

P: 8
Can you give me an example?
Feb 4 '15 #3

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

Rabbit
Expert Mod 10K+
P: 12,247
No problem, everyone makes these mistakes
Feb 4 '15 #5

P: 8
Can you check my other post? I'm still having issues.
Feb 5 '15 #6

Post your reply

Sign in to post your reply or Sign up for a free account.