Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7579821
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T17:45:56+00:00 2026-05-30T17:45:56+00:00

We were working on a mobile version of our site. Some programmers put up

  • 0

We were working on a mobile version of our site.

Some programmers put up this code on our normal non-mobile page. The result was that our site started to perform very slowly and bug out.

I’m thinking that the new mobile page may have had some bad code that was creating the issues, but I wanted to know if the code snippit put on our existing pages was problematic.

Here is is:

<?php
$iphone = strpos($_SERVER['HTTP_USER_AGENT'],"iPhone");
$android = strpos($_SERVER['HTTP_USER_AGENT'],"Android");
$palmpre = strpos($_SERVER['HTTP_USER_AGENT'],"webOS");
$berry = strpos($_SERVER['HTTP_USER_AGENT'],"BlackBerry");
$ipod = strpos($_SERVER['HTTP_USER_AGENT'],"iPod");

if ($iphone || $android || $palmpre || $ipod || $berry == true)
{
header('Location: http://m.site.com/index.php?id='.$HTTP_GET_VARS["id"]);
//OR
//echo "<script>window.location='http://mobile.site.com'</script>";
}

Someone from our hosting company suggested that the code maybe should have ‘===’ instead of ‘==’ at the end of the if statement.

Does the code look problematic?

Thanks as always.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T17:45:57+00:00Added an answer on May 30, 2026 at 5:45 pm

    First of all, I reccomend you to re-write:

    1. Avoid PHP to print HTML tags (alternate PHP syntax designed to solve this!)
    2. Use a header redirect and a regex.

    //this function just detects device:
    function detect_dev(){
      $devices = array();
      $devices['iPhone'] = 'iPhone';
      $devices['Android'] = 'Android';
      // add more
    
      foreach ($devices as $device => $name){
        if (preg_match("/$device/", $_SERVER['HTTP_USER_AGENT']){
        //ok, dev detected, return it's name 
        return $name;
      }
    }
    
    function redirect_sp_dev(){
      $device = detect_dev();
    
      // If it's not empty(mean device detected), do redirect: 
      if (!$device){
        redirect('your url with $device var');
      }
    }
    

    Also, some other notes, your URL is bad because I see it, and I already know how to hack your site. Read about XSS.

    Do not use $HTTP_GET_VARS.
    Do not use $_REQUEST

    Use $_GET or $_POST instead.

    1. I recommend you to rewrite url via mod_rewrite. Do it. It’s easy.
    2. DO NOT PUT everything into INDEX file.
    3. Read about MVC and PHP
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Some background I'm currently working on a mobile site so I keep switching user
I have a mobile version of my site working now and I want to
So I have been working on this phone gap application that uses jquery-mobile. Recently,
I'm working on a mobile view of our site. I'm trying to implement JQuery
Throughout a jQuery mobile site I am working on I have anchor tags that
I have a mobile version of my site and on the login page I
I got some radio controls that in JQuery Mobile 1.0.1 (stable) were working pretty
I am working on a mobile application in .NET. This is a windows mobile
I'm working on a mobile application (C#/WPF on a tablet PC) that prints to
I'm working on a Drupal mobile site which is powered by the Mobile module.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.