1. Halo Guest, pastikan Anda selalu menaati peraturan forum sebelum mengirimkan post atau thread baru.

[ASK] cara ambil $mobil = www.m.domain.com

Discussion in 'Pemrograman Web' started by wagimen, Nov 13, 2014.

  1. wagimen

    wagimen Newbie

    Joined:
    Nov 13, 2014
    Messages:
    34
    Likes Received:
    0
    PHP:
    <?php
     
    include("Mobile_Detect.php");
     
    $detect = new Mobile_Detect();
     if (
    $detect->isMobile()) {
      
    header("location:http m,domain,com");
     }

     
    ?>
    dan

    PHP:
    <?=$mobil?>

    gan gimana ya cara nggabunginya...???

    ane coba

    PHP:
    <?php
     
    include("Mobile_Detect.php");
     
    $detect = new Mobile_Detect();
     if (
    $detect->isMobile()) {
      
    header("location:$mobil");
     }

     
    ?>
    gak bisa

    PHP:
    <?php
     
    include("Mobile_Detect.php");
     
    $detect = new Mobile_Detect();
     if (
    $detect->isMobile()) {
      
    header("location:<?=$mobil?>");
     }

     
    ?>

    juga gak bisa :hmm:.....
     
  2. punxs

    punxs musuhnya google

    Joined:
    Dec 9, 2010
    Messages:
    448
    Likes Received:
    48
    Location:
    Di Depan Mu
    $mobil isinya apa?
    kalau
    Code:
    $mobil = www.m.domain.com
    coba tambahin http://
    Code:
    [COLOR=#000000] [COLOR=#0000BB]<?php
     [/COLOR][COLOR=#007700]include([/COLOR][COLOR=#DD0000]"Mobile_Detect.php"[/COLOR][COLOR=#007700]);
     [/COLOR][COLOR=#0000BB]$detect [/COLOR][COLOR=#007700]= new [/COLOR][COLOR=#0000BB]Mobile_Detect[/COLOR][COLOR=#007700]();
     if ([/COLOR][COLOR=#0000BB]$detect[/COLOR][COLOR=#007700]->[/COLOR][COLOR=#0000BB]isMobile[/COLOR][COLOR=#007700]()) {
      [/COLOR][COLOR=#0000BB]header[/COLOR][COLOR=#007700]('[/COLOR][COLOR=#DD0000]location:[/COLOR] http://'[COLOR=#DD0000].[COLOR=#000000][COLOR=#0000BB]$mobil[/COLOR][/COLOR][/COLOR][COLOR=#007700]);
     }
    [/COLOR][COLOR=#0000BB]?>[/COLOR][/COLOR]
    
     
  3. wagimen

    wagimen Newbie

    Joined:
    Nov 13, 2014
    Messages:
    34
    Likes Received:
    0
    gk bisa gan....
     
  4. xrvel

    xrvel Super Hero

    Joined:
    Oct 21, 2007
    Messages:
    2,873
    Likes Received:
    947
    Location:
    Di sini
    $mobil isinya apa?
     
  5. wagimen

    wagimen Newbie

    Joined:
    Nov 13, 2014
    Messages:
    34
    Likes Received:
    0
    isinya 'hatetepe : // m,domain,com/download-'.$search.'-k,html';

    $mobil = 'hatetepe : // m,domain,com/download-'.$search.'-k,html';
     
  6. xrvel

    xrvel Super Hero

    Joined:
    Oct 21, 2007
    Messages:
    2,873
    Likes Received:
    947
    Location:
    Di sini
    Kalau coba ini hasilnya apa?

    PHP:
    <?php
     
    include("Mobile_Detect.php");
     
    $detect = new Mobile_Detect();
     if (
    $detect->isMobile()) {
        
    header("Location: $mobil");
        exit();
     }
     
    ?>
    Kalau redirect gagal, apa ada pesan error? Misal warning headers already sent / semacamnya?
     
  7. wagimen

    wagimen Newbie

    Joined:
    Nov 13, 2014
    Messages:
    34
    Likes Received:
    0
    kagak gan.... ya gak bisa di buka gitu... kayak lagi habis kuota internet HP gitu
     
  8. wagimen

    wagimen Newbie

    Joined:
    Nov 13, 2014
    Messages:
    34
    Likes Received:
    0
    eh bisa gan.... :) tengkyu banget... mas xrvel
     
  9. xrvel

    xrvel Super Hero

    Joined:
    Oct 21, 2007
    Messages:
    2,873
    Likes Received:
    947
    Location:
    Di sini
    berarti mungkin kode di post 1 kurang "exit()" aja :)
     
  10. wagimen

    wagimen Newbie

    Joined:
    Nov 13, 2014
    Messages:
    34
    Likes Received:
    0

    ni ane mau buat versi web versi mobile gitu... ntar keredirect otomatis...



    PHP:
      <?php
     
    include("Mobile_Detect.php");
     
    $detect = new Mobile_Detect();
     if (
    $detect->isMobile()) 
     {
     
    header("Location: $mobil");
      }
      
    else
     
     {
     
    header("Location: $web");
      }
      
     
    ?>  
    kalau nambahi else gitu pener ato salah ya :D
     
  11. punxs

    punxs musuhnya google

    Joined:
    Dec 9, 2010
    Messages:
    448
    Likes Received:
    48
    Location:
    Di Depan Mu
    bener, tinggal tambahin
    ini_set("display_errors",0) dan exit
    untuk memastikan, jika ada warning gak error proses redirectnya
    PHP:
      <?php
    ini_set
    ("display_errors",0);
     include(
    "Mobile_Detect.php");
     
    $detect = new Mobile_Detect();
     if (
    $detect->isMobile()) 
     {
     
    header("Location: $mobil");
    exit;
      }
      
    else
     
     {
     
    header("Location: $web");
    exit;
      }
      
     
    ?>  
     
  12. wagimen

    wagimen Newbie

    Joined:
    Nov 13, 2014
    Messages:
    34
    Likes Received:
    0

    PHP:

      <?php
    ini_set
    ("display_errors",0);
     include(
    "Mobile_Detect.php");
     
    $detect = new Mobile_Detect();
     if (
    $detect->isMobile()) 
     {
     
    header("Location: $mobil");
    exit;
      }
      
    else
     
     {
     
    header("Location: $web");
    exit;
      }
      
     
    ?>



    versi web jadi gak bisa gan..... itu ane pasang di header versi web
     
  13. xrvel

    xrvel Super Hero

    Joined:
    Oct 21, 2007
    Messages:
    2,873
    Likes Received:
    947
    Location:
    Di sini
    tergantung di mana posisi kode itu. kalau kode itu juga ada di dalam versi web, tidak perlu diberi redirect kalau non mobile, karena nanti jadi redirect loop.
     
  14. wagimen

    wagimen Newbie

    Joined:
    Nov 13, 2014
    Messages:
    34
    Likes Received:
    0
    itu malah ane pasang di versi web gan....
     
  15. wagimen

    wagimen Newbie

    Joined:
    Nov 13, 2014
    Messages:
    34
    Likes Received:
    0
    tpi versi webnya jadi gak bisa di akses...... trus ane coba pakek HP... ane akses pakek link versi mobile... trus di redirect deh ke versi mobile
     
  16. wagimen

    wagimen Newbie

    Joined:
    Nov 13, 2014
    Messages:
    34
    Likes Received:
    0
    owh...

    jadi kodenya kalau gak di kasih redirect yang bener gimana gan....

    iya bener juga ya.... 1 redirect yang 1 kagak
    begitupun yang versi mobile nya
     
  17. punxs

    punxs musuhnya google

    Joined:
    Dec 9, 2010
    Messages:
    448
    Likes Received:
    48
    Location:
    Di Depan Mu
    default tampilannnya apa?
    kalau defaultnya versi web, ya gak perlu di kasih else
    nanti di looping redirectnya gak ada ujungnya, jadi gak bisa di akses akibatnya
     
    xrvel likes this.
  18. gudel

    gudel Ads.id Pro

    Joined:
    Dec 13, 2012
    Messages:
    269
    Likes Received:
    24
    Pasang code ini d index.php versi mobile.
    PHP:
    <?php
    session_start
    ();
    @include(
    "Mobile_Detect.php");
    $detect = new Mobile_Detect;
    $mobile $detect->isMobile();
    if (
    $mobile == FALSE)
    {
    header("Location: hxxp://domain(dot)com/");
    }
    ?>
    Trus pasang kode ini d index.php versi dekstop
    PHP:
    <?php
    session_start
    ();
    @include(
    "Mobile_Detect.php");
    $detect = new Mobile_Detect;
    $mobile $detect->isMobile();
    if (
    $mobile == TRUE)
    {
    header("Location: hxxp://m.domain(dot)com/");
    }
    ?>
    Contoh kalo url nya pake parameter buat d pasang d versi mobile,
    PHP:
    <?php
    session_start
    ();
    @include(
    "Mobile_Detect.php");
    $detect = new Mobile_Detect;
    $mobile $detect->isMobile();
    if ((
    $mobile == FALSE) && isset($_GET['q']))
    {
    header("Location: hxxp://domain(dot)com/search?q=".urlencode($_GET['q']));
    }
    ?>
     
  19. articlegig

    articlegig Hero

    Joined:
    Oct 20, 2010
    Messages:
    689
    Likes Received:
    37
    Location:
    Surabaya
    content dari Mobile_Detect.php apa gan? bisa dipaste sekalian? variabel $mobil itu kosong, jadi g bisa redirect.
     
  20. wagimen

    wagimen Newbie

    Joined:
    Nov 13, 2014
    Messages:
    34
    Likes Received:
    0
    work gan..!! tengkiyu :senyum: ....
     

Share This Page