PHP code for redirect

Started by Charter, 05-23-2010, 17:27:40

Previous topic - Next topic

CharterTopic starter

Hi, I designed a web site for a client, and I got thisredirect script to work on IPHONE, but it doesnt work on blackberry at all, even if I replace the 'iphone' with 'blackberry'.

Any help GREATLY appreciated! Cant get this thing to work!

<?php if (strpos($_SERVER['HTTP_USER_AGENT'], 'iPhone') !== FALSE)
header('Location: http://www.israla.com/mobile/index.php'); }
?>


  •  


ryosuzuki

Not sure about this one, but it depends if the useragent recognises blackberry. It may not.... Mobile recognition in modern day browsers is still young.....


thelazytrader

You have to used php's inbuild function header(). and redirect your script as you like.

mmeetkaur3

#3
However, the issue seems to be that the script doesn't work for Blackberry devices even after replacing 'iPhone' with 'Blackberry'.

You may want to consider using a different approach to detect the user's device and perform the redirection. There are more robust methods for device detection, such as using responsive design techniques or employing server-side libraries like WURFL.

Here are a few examples of code in different programming languages:

1. Python:
def greet(name):
    print("Hello, " + name + "!")


2. JavaScript:
function greet(name) {
    console.log("Hello, " + name + "!");
}


3. Java:
public class Greeting {
    public static void greet(String name) {
        System.out.println("Hello, " + name + "!");
    }
}


4. C++:
#include <iostream>
using namespace std;

void greet(string name) {
    cout << "Hello, " << name << "!" << endl;
}
http://www.zaydenmortgage.ca/ , http://www.heightincrease.in
, http://www.sharekhantips.com/
  •  

sedoman001

Hi I am new in this forum and looking PHP video. Please help me. Thank you.
  •  


pstpl1

header('Location:  destination.php');
exit();

This header function is used to direct page eassly
ERP Software [nofollow]
Payroll Software [nofollow]
  •  

Hi-Tech ITO

You must use the inbuild PHP function header (). and redirect the script you want.
  •  

johncruz

<script type="text/javascript">
onload=function(){
if ((screen.width <= 800) || (navigator.userAgent.match(/blackberry/i)) {
window.location.href = "mypageurlhere.htm";
}
}
</script>


This will help you but for Blackberry in WAP/WML modes, this code will not work, as I believe that in those cases JavaScript is disabled.
  •