For starters the above code just won't work. Even if I code a simple index.html and a simple index.wml on seperate pages to use the else. I checked the syntax with minor adjustment. Won't work.
After hours and hours of research I came across an interesting snipet of code. ===
HELP
Wireless services and WAP Return to Help menu
Introduction to WAP
Introduction to WML
Introduction to XML
Reasons to use WML
Viewing WAP sites without a wireless device
WAP and domain names
WAP file extensions
WML file location
WML file permissions
WAP images
More information about WAP, WML and XML
Introduction to WAP
WAP stands for Wireless Application Protocol, although in reality WAP is a collection of protocols and specifications. The purpose of this standard is to serve information and services on the Internet to wireless clients and WAP devices, such as mobile phones and terminals. The authoritative source for WAP is www.wapforum.org.
Top of Page
Introduction to WML
WML (Wireless Markup Language) is a markup language based on XML. Technically it is an XML application. Just like HTML and XML, WML is read and interpreted by a browser built into the WAP device. For WAP devices, the browser is commonly called a micro browser, indicating that its capabilities are somewhat limited. Additional limitations may be the result of the device that the micro browser runs on. If you have no prior knowledge of XML, you will probably find WML much more stringent than HTML.
WML files are referred to as "decks". Each deck consists of one or more cards. Cards begin and end with <card> tags, while decks begin and end with <deck> tags. When the WML micro browser accesses a WML document (or deck), it reads the whole deck. Therefore, it doesn't need to load any more data to navigate between cards. The <card> tag in WML is very similar to the <a name> tag of HTML.
WAP devices have very little memory, so there is a limit to how big each WML deck can be. The limit varies a great deal from one browser to another. These limits refer to the compiled form of your deck, which is usually fairly small compared to the plain text XML code that you send out from the server.
Example:
<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">
<wml>
<card id="card1" title="Card 1">
<p>
Hello World!
</p>
</card>
<card id="card2" title="Card 2">
<p>
Hello World!
</p>
</card>
</wml>
Top of Page
Introduction to XML
The Extensible Markup Language (XML) is a subset of SGML that was designed especially for Web documents. It allows the creation of customized tags, and it enables the transmission and interpretation of data between applications and between organizations.
Top of Page
Reasons to use WML
WML is used in the WAP environment instead of HTML. WML is designed for wireless devices. Compared to HTML, WML requires very little bandwidth and much less processing strength to render, which means longer lasting batteries. Finally, HTML requires a larger display than is available on a mobile phone.
Top of Page
Viewing WAP sites without a wireless device
WML can be read by any micro browser and a variety of emulators. Some of them require installation of components such as Java Runtime. You should test with more than one of these tools, and verify that you are using an emulator that accurately simulates the devices you are ultimately targeting.
Top of Page
WAP and domain names
It is very practical to re-use already existing HTML code, so it can be beneficial to have your first page (homepage) differentiate between a desktop HTML browser and a mobile WML browser and serve content accordingly. This allows the same URL (yourname.com) to be used to view both your HTML site and your WAP site.
The PHP code below allows you to do just that. Implement this code into an INDEX.PHP page, before any of your site content is loaded. It will first attempt to identify what type of browser is trying to hit your site. If the PHP code identifies a WAP user from the list of possible WAP browsers, it will direct the user (seamlessly) to the specified WML pages. If it does not identify a WAP browser or any browser at all, it will redirect to your specified HTML page.
Advanced Implementation: This has to be done on the server side, and the following PHP code will first attempt to discover if the WAP gateway being used can accept the text/vnd.wap.vml MIME type. If not, it will check the first four characters in the ID string to determine if it's a WML browser. If there's no match, it's assumed that it's an HTML browser. As new WML browsers come along, their ID strings should be added to the list.
The code is based on Robert Whitinger's (robert@wapsight.com) code submitted to the PHP mailing list, with several additions for browser ID string from Don Amaro's (donamaro.concepcion@nl.unisys.com) log files.
Example code:
<?
// Because this script sends out HTTP header information,
// the first characters in the file must be the <? PHP tag.
$htmlredirect = "/html/my_htmlpage.html"; // relative URL to your HTML file
$wmlredirect = "http://wap.mysite.com/wml/my_wmldeck.wml"; // ABSOLUTE URL to your WML file
if(strpos(strtoupper($HTTP_ACCEPT),"VND.WAP.WML") > 0) { // Check whether the browser/gateway
$br = "WML"; // says it accepts WML.
}
else {
$browser=substr(trim($HTTP_USER_AGENT),0,4);
if($browser=="Noki" || // Nokia phones and emulators
$browser=="Eric" || // Ericsson WAP phones and emulators
$browser=="WapI" || // Ericsson WapIDE 2.0
$browser=="MC21" || // Ericsson MC218
$browser=="AUR " || // Ericsson R320
$browser=="R380" || // Ericsson R380
$browser=="UP.B" || // UP.Browser
$browser=="WinW" || // WinWAP browser
$browser=="UPG1" || // UP.SDK 4.0
$browser=="upsi" || // another kind of UP.Browser ??
$browser=="QWAP" || // unknown QWAPPER browser
$browser=="Jigs" || // unknown JigSaw browser
$browser=="Java" || // unknown Java based browser
$browser=="Alca" || // unknown Alcatel-BE3 browser (UP based?)
$browser=="MITS" || // unknown Mitsubishi browser
$browser=="MOT-" || // unknown browser (UP based?)
$browser=="My S" || // unknown Ericsson devkit browser ?
$browser=="WAPJ" || // Virtual WAPJAG www.wapjag.de
$browser=="fetc" || // fetchpage.cgi Perl script from www.wapcab.de
$browser=="ALAV" || // yet another unknown UP based browser ?
$browser=="Wapa") // another unknown browser (Web based "Wapalyzer"?)
{
$br = "WML";
}
else {
$br = "HTML";
}
}
if($br == "WML") {
header("302 Moved Temporarily"); // Force the browser to load the WML file instead
header("Location: ".$wmlredirect);
exit;
}
else {
header("302 Moved Temporarily"); // Force the browser to load the HTML file instead
header("Location: ".$htmlredirect);
exit;
}
?>
====
Now you will all say WOW. However from what I gather (and I spent 6 grewling hours on this.) there has to be multiple phone ID's ect... After implementing the above code. I STILL GET A BLANK PHP index and the phone sends back a INTERNET 500 Error. At least its a bit better than nothing.
This is starting to look like a million dollar question. It seems everyone is trying to figure out how to do this.
I'll keep everyon posted. If anyone has anybetter ideas or would like actual code I am using let me know I'll gladly supply it.
Thanks for all your amazing help and if I find a solution I will post it here so at least some other fella doesn't bump into the same problem.