473,461 Members | 2,308 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

how to detect page request is from mobile or PC?

Hi Everybody,

I have developed a website using PHP, which will produce HTML code.

But I have some pages in PHP ,which will produce WML code for mobile browsers.

I want to redirect to WML page,if the site is accessed from the mobile. Otherwise it should display HTML page if the site is accessed from Desktop PC.

Please do reply me.

Arun.
Apr 4 '07 #1
4 5650
michaelb
534 Expert 512MB
I think you could use a simple javascript code to detect the client
(run a Google search for "javascript browser detection")
and redirect accordingly.
Apr 4 '07 #2
I think you could use a simple javascript code to detect the client
(run a Google search for "javascript browser detection")
and redirect accordingly.
As the javascript is running in the client side,some mobile browsers will not support "Javascript". So I want to achieve the same in the server side itself.

(i.e) In the server, I want to know which device (whether mobile or Desktop Computer) is acessing the website.

If the device accessing the website is a mobile or PDA , then it should redirect into a PHP page which will produce WML code.

Otherwise if the request is from computer, then it should redirect into a PHP page which will produce HTML code.
Apr 5 '07 #3
michaelb
534 Expert 512MB
>> ... some mobile browsers will not support "Javascript".
Sorry, I overlooked this.

Back to the server code, when you use a mobile device is $_SERVER['HTTP_USER_AGENT'] gets some meaningful value?
Apr 5 '07 #4
Hi Everybody,

I have developed a website using PHP, which will produce HTML code.

But I have some pages in PHP ,which will produce WML code for mobile browsers.

I want to redirect to WML page,if the site is accessed from the mobile. Otherwise it should display HTML page if the site is accessed from Desktop PC.

Please do reply me.

Arun.




this is the script....this is s php type...





<?php
/////////////////////////////////////////////////////////////////////////////
///************************************************** ****************///////
///*PROYECTO WAP CONSULTA DE NOTAS-CORPORACION UNIVERSITARIA DE CIENCIA*////
///*Y DESARROLLO UNICIENCIA-EXTENSION BUCARAMANGA.*********************////
///*TESIS PRESENTADA POR: JOSE ALVAREZ VERGARA-INGENIERIA INFORMATICA*////
///************************************************** ******************//
////////////////////////////////////////////////////////////////////////

//PROTECCION DE NAVEGADOR
$user = explode ('/', $HTTP_USER_AGENT);
//EL ACCESO ESTA DENEGADO PARA CUALQUIERA DE ESTOS NAVEGADORES Y SERA REDIRECCIONADO A LA PAGINA PRINCIPAL DE LA U
if($user[0]=="Opera"||$user[0]=="Mozilla"||$user[0]=="Go!Zilla"||$user[0]=="Netscape"||$user[0]=="MSIE"){
//PAGINA COMPATIBLE A LA CUAL SE REDIRECCIONA
header ('Location: http://www.unicienciabga.edu.co/wap/error.php');}

//EN CASO QUE SEA UN NAVEGADOR WAP COMPATIBLE SE PERMITIRÁ EL ACCESO
include("parametros.inc");
?>

<wml>
<card ontimer='inicio.wml#main' title='<? echo $SITENAME; ?>'>
<timer value="50"/>
<p align='center'>
<small> SISTEMA WAP<br/>
<strong>Uniciencia Bucaramanga</strong></small><br/>

<img src="./images/uniciencia.jpg" alt="Uniciencia"/><br/>

<small>Educacion Integral de Optima Calidad</small><br/>
<small><a href='inicio.wml#main'>Ingresar</a></small>
</p>

</card>
</wml>
Jun 10 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: ripken95 | last post by:
I connect to the internet through ADSL. I want to write the web page which can detect the connection status with javascript. This detection is like the signal detection in the mobile phone. If the...
3
by: Sara | last post by:
HI, I want to code a program to detect GSM mobile (any kind) which connected through serial port to computer and then be able to send SMS through this mobile phone to other mobile phones, could...
6
by: hb | last post by:
Hi, Would you please tell me how to detect if the client's browser is closed? I need such event to trigger a database modification. Thank you hb
3
by: Carlos | last post by:
Hi all, I was just trying to execute sample code to redirect the output to a mobile page from a Pocket PC but it did not work. I tried from the root aspx file (page_load event): if...
4
by: Sara | last post by:
Hi I want to code a program which could send SMS through web page to mobile phone, but because there is no Service here such as SMPP , therefore I have GSM mobile phone which connected directly to...
4
by: SJ | last post by:
I have a mobile web application running on a server at work. There is a strange thing happening though: 1) I can access and login to my mobile web app from any internet browser. (good thing). 2)...
4
by: David Thielen | last post by:
Hi; This is for a website that is just html pages, no ASP.NET. I want the default page to be a different page if it's a mobile device. I can do this in ASP.NET by looking at the browser size and...
8
by: barrybee | last post by:
PHP version 4.027 I want to change between style sheets when page is viewed on a mobile phone or a PC. The pages looks fine on both when I manually set a key in the script. My problem is how to...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.