View previous topic :: View next topic |
Author |
Message |
chewzzqq -
Joined: 28 Sep 2005 Posts: 198
|
Posted: Mon Apr 17, 2006 6:49 pm Post subject: need help for php code |
|
|
please ,any one who know how to write php code....
i want 2 make two site.
one is for wap site
one is for web site
so,how to write a script at index.php
when use web browser to go to my mainpage.it will auto go to web page.
like auto go to (www.xxxx.com/web/index.php)
or
when use phone browser to view,it will auto detect,
and go to (www.xxxx.com/wap/index.php)
who can help me?
thanks _________________
 |
|
Back to top |
|
 |
techieJimbo -
Joined: 15 Apr 2006 Posts: 5
|
Posted: Tue Apr 18, 2006 2:14 am Post subject: get_browser |
|
|
Use
http://us2.php.net/manual/en/function.get-browser.php
You need to download get php_browscap.ini from site (available through link on page above). Put it in any directory, best to put it in PHP install directory.
Edit php.ini:
- Edit browscap directive to include full path to file (example: browscap = "C:\php\php_browscap.ini")
By default your server should redirect automatically to index.php. At the top of index.php put code:
Code: |
<?PHP
$browser = get_browser(null, true);
if ($browser['wap'] == true)
header("Location: /wap/index.php");
?>
|
Note that I used null and true values as parameters in get_browser. This tells the the function to bypass the custom HTTP parameter (null) and return information as an array (true). This is only available in PHP 4.3.2+, if you use an older version it will probably throw an error. You would have to use the function without parameters. In that case the function would return an object and you would have to alter the code slightly. _________________ - Jim |
|
Back to top |
|
 |
chewzzqq -
Joined: 28 Sep 2005 Posts: 198
|
Posted: Tue Apr 18, 2006 3:39 am Post subject: |
|
|
thx for reply
i use php5..
but still confuse with the code...
wait,give me some time...
b coz my english not very well _________________
 |
|
Back to top |
|
 |
chewzzqq -
Joined: 28 Sep 2005 Posts: 198
|
Posted: Tue Apr 18, 2006 4:29 am Post subject: |
|
|
i just put this code at htdocs --> index.php
Code: | <?PHP
$browser = get_browser(null, true);
if ($browser['wap'] == true)
header("Location: /wap/index.php");
?>
|
but when i go to my site using nokia phone wap browser,
it coming up this message
(Compiler did not find HTML tag) _________________
 |
|
Back to top |
|
 |
Tom Chapman -
Joined: 09 Jul 2005 Posts: 933 Location: Australia
|
Posted: Tue Apr 18, 2006 7:45 am Post subject: |
|
|
I don't know anything about Phone browsers but by the sounds of it your 'WAP Browser' only supports files with HTML or HTM extentions. |
|
Back to top |
|
 |
chewzzqq -
Joined: 28 Sep 2005 Posts: 198
|
Posted: Tue Apr 18, 2006 10:28 am Post subject: |
|
|
thx for reply.
i understand what it say already...
anyway,i was thinking what should i have to post at web page?
or just close the wap site?
b coz i dunno how to write this script _________________
 |
|
Back to top |
|
 |
TRUSTAbyss -
Joined: 29 Oct 2003 Posts: 3752 Location: USA, GA
|
Posted: Tue Apr 18, 2006 1:17 pm Post subject: |
|
|
Dude! Try this! :-)
01. Download "php_browscap.ini" from:
http://www.garykeith.com/browsers/downloads.asp
02. Put this file in C:/PHP/extras
03. Open your php.ini, located in C:/PHP or C:/Windows and edit the
following settings in your php.ini file. This should be easy. :-)
Quote: | [browscap]
browscap = C:/PHP/extras/php_browscap.ini
|
Copy the code and name it "index.php", put this file in your htdocs.
You now have both WAP and WEB support for your website.
Code: | <?php
$browser = get_browser(null, true);
if ($browser['wap'] == TRUE) {
header('Location: /wap/index.php');
exit;
} else {
header('Location: /web/index.php');
exit;
}
?>
|
Did this solve your WAP and WEP support problem?
Note: You should update your "php_browscap.ini" file as new updates
become available, in order to keep track of it.
Sincerely, TRUSTpunk |
|
Back to top |
|
 |
chewzzqq -
Joined: 28 Sep 2005 Posts: 198
|
Posted: Tue Apr 18, 2006 3:19 pm Post subject: |
|
|
thx a lot ,my friend
i will try now _________________
 |
|
Back to top |
|
 |
chewzzqq -
Joined: 28 Sep 2005 Posts: 198
|
Posted: Tue Apr 18, 2006 3:37 pm Post subject: |
|
|
o k,i done it
thx a lot _________________
 |
|
Back to top |
|
 |
TRUSTAbyss -
Joined: 29 Oct 2003 Posts: 3752 Location: USA, GA
|
Posted: Tue Apr 18, 2006 7:05 pm Post subject: |
|
|
No problem. |
|
Back to top |
|
 |
|