473,325 Members | 2,712 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

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

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
5 1237
Rabbit
12,516 Expert Mod 8TB
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
Can you give me an example?
Feb 4 '15 #3
Ahhh you know what you're absolutely right. I named it zipcode in the array.... Stupid of me thanks
Feb 4 '15 #4
Rabbit
12,516 Expert Mod 8TB
No problem, everyone makes these mistakes
Feb 4 '15 #5
Can you check my other post? I'm still having issues.
Feb 5 '15 #6

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

Similar topics

7
by: Dave A | last post by:
I have two events in a form that I am passing. One is to a javascript function, the other is to the same .asp page only with another action to show different data. Onchange is calls the...
8
by: CHouck | last post by:
I have what seems to be a simple problem but I can't figure it out. I have a page where I have a link with variables built in which I want to pass through the URL so another page can pick the...
9
by: Max | last post by:
I'm new with Javascript and can't seem to figure out what I'm doing wrong here as I'm not able to pass a simple variable to a function. In the head of doc I have: <script...
3
by: David Bacon | last post by:
Hi All, I am new to C#, and am having trouble passing the value of a variable from one windows form to another. Can anyone point me in the right direction. Any help here would be greatly...
5
by: Paul | last post by:
Just wondering if someone could provide an example of passing a variable from the code behind to javascript in vb. I want to have one control have focus with the page loading with one condition...
5
by: glenn | last post by:
Hi folks, The problem I have is that a query string works if hard-coded but if I pass a variable to it, it does not work as shown here. This works: querystring="SELECT * FROM USERS WHERE...
1
by: markclinn | last post by:
I need help with passing a variable from embedded WebBrowser to VB application. I have an interactive map, and when I click on an icon, I need to pass the ID back into the application. Any ideas? ...
6
by: kkshansid | last post by:
<?php echo"<select name=$sarea >"; $option = "<option value=\"Please select a Subject Area\">Please select a Subject Area</option> \n"; for ($i = 0; $i < count($subjarea); $i++) {...
2
by: sunnypirate | last post by:
The following code treats abcd as a variable and gives the error variable undefined in firebug return $data = "<a href='#' onclick='ajaxcall(abcd);'>".$name."</a>"; The following code gives the...
1
by: jerrysc | last post by:
I have a problem I've been trying to work through, to which I think there is a probably a simple solution I am missing. I am trying to pass a variable from php to javascript. Seems like it should be...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.