Log in

View Full Version : Issue using "case" and redirect!



tonyking
03-28-2008, 07:03 PM
Please note, this is an old, existing post I am now having further problems with. This "simple" script is supposed to match a user inputted name, to a coresponding page.

This code is now presenting me with a problem in IE, and I can't for the life of me figure out why!? I am using a page called registry.php, here's the code:



<?php
if(isset($_POST['Submit'])){
$name = strip_tags($_POST['name']);
$name = strtolower($name);
switch($name){
case "haynes":
$page = 'haynes.html';
break;
case "bill":
$page = 'bill.html';
break;
case "bart":
$page = 'bart.html';
break;
default:
$page = "noregistry.html";
break;
}
header("Location:$page");
}
?>


And I am using the below form to post to the script.



<form name="Submit" method="post" action="registry.php">
<input type="text" name="name" class="cleardefault" size="20" value="Groom's Last Name" /><br />
<font size="-2" color="#0099FF">(Use ALL lowercase letters)</font><br /><br />
<input type="Submit" name="Submit" value="Submit" />
</form>


It works in firefox, and upon original testing, it worked in IE. Now when I test in IE it takes me to the registry.php page and stops. The script does not redirect to the appropriate case or page.

Here's the live example:
www.damartravel.com/honeymoons.html
You can see the form in the left hand column.

Here's the direct link to the page it should redirect to:
www.damartravel.com/haynes.html (http://www.damartravel.com/haynes.html)

Hopefully this is something silly, and one of you know what it is! lol... It's been driving me crazy all morning.

Thanks in Advance.

NXArmada
03-28-2008, 07:06 PM
I just went to the site in Both Firefox and IE and it worked fine for me, when i put haynes in the box.

I get page not found on both bart and bill

tonyking
03-28-2008, 07:19 PM
Odd, may I ask what version of IE you used? As I've tried this on several computers in our office producing the same results.

JazzcatCB
03-28-2008, 08:48 PM
It worked fine for me in IE7.

tonyking
03-28-2008, 09:00 PM
Very weird, I'm testing on IE7 myself, and have used multiple computers in our office. I hate just saying oh well, and moving on, but at this point I don't know what to do. Hopefully it works for everyone but me??

Nile
03-28-2008, 09:19 PM
What if you replaced:


header("Location:$page");

With:


header("Location: ".$page);

tonyking
03-28-2008, 09:32 PM
I FIGURED IT OUT!!!! Sort of.... Atleast I have narrowed it down! Nile I appreciate the reply, I tried that and it resulted in the same thing, BUT!

I have discovered when I click the submit button everything works fine in IE. However, when the user presses 'Enter' and submits the form, IE users (atleast IE7 users) are directed to a blank registry.php page. Why and how I don't freakin know, but I don't think it's an issue with the php, possibly the javascript I am using to clear the default text in the box?

Thanks everyone for your help, I've transfered this to the Javascript forum. Hopefully I can get this bug fixed there!

New Thread:
http://www.dynamicdrive.com/forums/showthread.php?t=30905

NXArmada
03-31-2008, 06:17 PM
Odd, may I ask what version of IE you used? As I've tried this on several computers in our office producing the same results.

I am using IE7