If IE browser do this if firefox do that...

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
murph2481
Forum Newbie
Posts: 20
Joined: Mon Jun 27, 2005 1:48 pm

If IE browser do this if firefox do that...

Post by murph2481 »

How do i write an if function that based on the browser that the surfer is using it does something different?

I want a function that does

If Microsoft IE then:
<link>http://user+domain.com@ftp.domain.com</link>

if Firefox then
<link>http://user@domain.com@ftp.domain.com</link>

My FTP server always adds a @domain.com to each user name. I want a link that will link the user into the FTP site and ask for a password for that user. IE and Firefox handle it very differently.

Thanks,
Dan
:D
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

use get_browser() if possible.. I've written a "local" version of it before, but it wasn't very fun (ran a bit slow due to huge file to parse to pull all the browser data)

alternately, you can use a basic regex against the user agent found in $_SERVER['HTTP_USER_AGENT']

unfortunately, both bank on whether the client is sending the "correct" agent string... :?


Alternately, you could use a bit of Javascript, which roughly does the same as checking the user agent...
Post Reply