Jump to content

PHP header() and Safari Problems?


drewjoh

Recommended Posts

I recently put together a quick interface for a store system at [a href=\"http://store.hihowareyou.com/\" target=\"_blank\"]http://store.hihowareyou.com/[/a]

The problem is, people with the Apple Safari browser seems to have a problem adding things to the shopping cart. They just get a blank screen.

The way the script works, is adding something to the cart makes a POST to actions.php, which then does the requested action (in this case, add something to the cart) and then forwards them to the next page using:
header("Location: [a href=\"http://store.hihowareyou.com/shopcart")\" target=\"_blank\"]http://store.hihowareyou.com/shopcart")[/a]

This method works for all other browsers, but Safari seems to have big problems with it?

I don't have a Mac to test this on, so I'm wondering if anyone else has had this problem or has any idea what might be the problem? Numerous Google searches don't seem to show anyone else having noticed/had this problem.

Thanks :)
Link to comment
Share on other sites

I just checked your page using curl... Ha! Funny.

It is "detecting" Safari and dumping me to an error page, saying "known issue with safari" -- but no header redirect... here's exactly what's being returned -- including header:
[code]HTTP/1.1 200 OK
Date: Fri, 28 Apr 2006 22:25:49 GMT
Server: Apache/1.3.34 (Unix) PHP/5.1.2 mod_auth_passthrough/1.8 mod_log_bytes/1.2 mod_bwlimited/1.4 FrontPage/5.0.2.2635 mod_ssl/2.8.25 OpenSSL/0.9.7a
X-Powered-By: PHP/5.1.2
Set-Cookie: PHPSESSID=124f41770823f1e368aed981e0893f13; path=/
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Transfer-Encoding: chunked
Content-Type: text/html

You appear to be using an incompatible or older version of the Apple Safari browser. You may try updating your browser.<br><br>
                There is a known redirect issue with Safari causing this page to be blank.<br><br>
                Other browsers such as <a href="http://www.mozilla.com/">Mozilla FireFox</a> and the
                <a href="http://www.opera.com/">Opera</a> browser are both excellent free alternatives for Mac OS X.[/code]

see? no "Location: " header at all.
Link to comment
Share on other sites

lol, yeah... I forgot I had put that error message in there. It doesn't redirect it to an error page or anything. I just output that text if I detect they're using safari (output buffer is on, so it won't interfere with a header())

I took the error message out, just in case.

Thank you, thank you though, that is the kind of information I'm needing.

Can you try it in Safari and then also in IE or Firefox and see if the header information is the same? :)

Also, if they aren't the same (which is what I think is happening), any idea why Safari isn't getting the header information?
Link to comment
Share on other sites

I didn't' use safari, I just told your site I was using safari :)

If I tell it I'm internet explorer, I get the following:
[code]HTTP/1.1 200 OK
Date: Fri, 28 Apr 2006 22:58:07 GMT
Server: Apache/1.3.34 (Unix) PHP/5.1.2 mod_auth_passthrough/1.8 mod_log_bytes/1.2 mod_bwlimited/1.4 FrontPage/5.0.2.2635 mod_ssl/2.8.25 OpenSSL/0.9.7a
X-Powered-By: PHP/5.1.2
Set-Cookie: PHPSESSID=124f41770823f1e368aed981e0893f13; path=/
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Transfer-Encoding: chunked
Content-Type: text/html
[/code]

Still no Location header, though.

Firefox and internet explorer work (but the page looks like crap in IE -- it's 200% wider than my screen with all kinds of whitespace. but hey, IE has been dead on Mac since, what, 2003?)

Question: how are you "detecting" the output buffer status?
Link to comment
Share on other sites

At the beginning of my script I use ob_start() :)

That's interesting there's no Location header.

The effect I get when using this method is: it never appears that it went to the actions.php page and then was redirected to /shopcart. So that when you click "Back" on your browser, you don't go to the actions.php page, it goes to the original page you were on.

Is the page you're seeing the shopcart of the actions.php page?

Also, how can I send it different headers and test things out? (I think that's what you're doing? You're not using a browser but something else that sends it the proper headers?)
Link to comment
Share on other sites

The solution might simpler than you thought. After clicking the "add to cart" on one of your items, this is the address I get thrown to:

[code]http://store.hihowareyou.com/shopcart/actions.php?------------0xKhTmLbOuNdArY%0D%0AContent-Disposition:%20form-data;%20name=%22a%22%0D%0A%0D%0Aadd%0D%0A------------0xKhTmLbOuNdArY%0D%0AContent-Disposition:%20form-data;%20name=%22id%22%0D%0A%0D%0A26%0D%0A------------0xKhTmLbOuNdArY%0D%0AContent-Disposition:%20form-data;%20name=%22submit.x%22%0D%0A%0D%0A61%0D%0A------------0xKhTmLbOuNdArY%0D%0AContent-Disposition:%20form-data;%20name=%22submit.y%22%0D%0A%0D%0A17%0D%0A------------0xKhTmLbOuNdArY%0D%0AContent-Disposition:%20form-data;%20name=%22submit%22%0D%0A%0D%0Asubmit%0D%0A------------0xKhTmLbOuNdArY--%0D%0A[/code]

Funny thing is, the form data I'm "submitting" isn't included -- or is obfuscated beyond recognition.

Now, curl seems to be happier (now that I'm actually posting data -- oops).

You might strip the form name tags -- you aren't using javascript to validate, so that shouldn't matter anyway -- maybe having duplicate form names is throwing safari for a loop?
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.