Jump to content

Help with creating a MOBILE clone of my site - using $_SERVER['HTTP_USER_AGENT]


jeger003

Recommended Posts

hi everyone,

i am trying to create a code for my site to detect mobile phone users. it would redirect them to a replica of my site like mobile.mysite.com and it would be completely text....

 

my issue is detecting the users mobile device..i used many scripts and none have done the job or even detected the mobile phones

 

i want to start out by

 

if ( $_SERVER['HTTP_USER_AGENT'] --something like "IS LIKE"-- iphone) 

cause i cant do 

if ($_SERVER['HTTP_USER_AGENT'] = iphone) that would mean the entire user agent is "iphone" which it wont be

 

i would appreciate help

 

LINKS TO TUTORIALS WOULD HELP!!

Link to comment
Share on other sites

You can use CSS instead, and serve up a different stylesheet just for mobile devices. In this manner, you don't have to do a redirect, duplicate content, or even create a different site, you just re-style the content.

 

A normal stylesheet links like this:

 

<link rel="stylesheet" src="style.css" type="text/css" />

 

You can add extra stylesheets, and use the 'media' attribute:

 

<link rel="stylesheet" src="style.css" type="text/css" media="screen" /> // for computers
<link rel="stylesheet" src="style.css" type="text/css" media="handheld" /> // for cellphones

Link to comment
Share on other sites

my site consists on many images that are "drag and dropped" on the page......not cssed onto it...how do i get around that?

 

 

and as for "media=handheld" is the page going to detect it as a handheld device and use the appropriate style sheet?

 

thank you haku

Link to comment
Share on other sites

ok, im testing out what you've recommended but im not really sure how it supposed to work...

 

i create two of the same style sheets? or do i create two styles one for PC one for Mobile?

 

how do i specify it on a font or something

 

i.e

 

<style=PC-font> word here </style>

 

how do i use the mobile-font on the same thing?

 

and as for the image part......well i have an image at the top....that shrinks when loaded in the browser and it really expands and displaces everything else

Link to comment
Share on other sites

my site consists on many images that are "drag and dropped" on the page......not cssed onto it...how do i get around that?

 

Not sure what you mean by this.

 

i create two of the same style sheets? or do i create two styles one for PC one for Mobile?

 

Two different sheets - one for PC and one for Mobile. The device itself will know whether it is a PC or a mobile, and will (or at least should) only download the appropriate stylesheet.

 

To specify a font, place it in the appropriate stylesheet. You don't need any special declaration.

 

and as for the image part......well i have an image at the top....that shrinks when loaded in the browser and it really expands and displaces everything else

 

Set it as a background image in your CSS for the PC stylesheet. In the mobile stylesheet, specify a different image for the background image (one that is made for a phone-sized screen).

Link to comment
Share on other sites

this is an awesome IDEA!!!! works great

 

the other thing i wanted to do was to actually redirect mobile users to a different url like mobile.sitename.com

 

because i wanted to create a page for mobile users to be able to just make purchases....it wouldn't have any of the texts or images......just a few "buy now" buttons

 

any idea how i can go about that?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.