2013-03-08 4 views
0

나는 약간의 어려움에 직면 해 있습니다. 웹 사이트와 모바일 버전이 있습니다. 휴대 전화를 사용하는 사용자가 페이스 북과 같은 다른 사이트의 링크를 클릭하면 사용자가 선택한 링크의 콘텐츠를 표시하는 모바일 사이트로 리디렉션되기를 원합니다.휴대 전화에서 선택한 데스크톱 웹 링크를 모바일 사이트로 리디렉션

성취 :

내가 모바일 페이지에 데스크톱 버전에서 사용자를 리디렉션 할 수 있었다.

도전

내가 선택한 링크 예컨대 http://passnownow.com/inblog.php?id=3840#.UToTf3YetfU.twitter의 내용을 표시 할 수 없습니다입니다.

사용자가 게시물을 검색해야하는 모바일 사이트로만 이동합니다.

내가 무엇을 할 수 있습니까?

이것은 내 코드입니다.

<? include("overall.php");?> 
<? 

session_start(); 

require_once('mobile_device_detect.php'); 

$blackberrystatus = mobile_device_detect(true,true,false,true,true,true,true,false,false); 

$androidstatus = mobile_device_detect(true,true,true,true,false,true,true,false,false); 

$mobile = mobile_device_detect(true,true,true,true,true,true,true,false,false); 
$isMobile = (bool)preg_match('#\b(ip(hone|od)|android\b.+\bmobile|opera m(ob|in)i|windows (phone|ce)|blackberry'. 
        '|s(ymbian|eries60|amsung)|p(alm|rofile/midp|laystation portable)|nokia|fennec|htc[\-_]'. 
        '|up\.browser|[1-4][0-9]{2}x[1-4][0-9]{2})\b#i', $_SERVER['HTTP_USER_AGENT']); 

if($_GET["view"]=="full"){ 

    setcookie("passnownow[client]", "pc", $time + 1209600); 

    $_SESSION["client"] = "pc"; 

    } 

if ($_GET["ref"]=="android" or $_GET["ref"]=="blackberry"){ 

    setcookie("passnownow[client]", "app", $time + 1209600); 

    $_SESSION["client"] = "app"; 


    header('location: mobile/new.php?id=""'); 

    } else if ($_SESSION["client"]=="pc" or $_COOKIE['passnownow']["client"]=="pc"){ 



     }else if ($mobile or $isMobile){ 

    setcookie("passnownow[client]", "mobile", $time + 1209600); 

    $_SESSION["client"] = "mobile"; 


    **header('location: mobile/new.php?id=""');** 

     } 

    include("overall.php"); 

?> 

내 질문은 : 내가 선택한 링크 등을 표시 할 header('location: mobile/new.php?id=""');을 전달할 수있는 방법을 header('location: mobile/new.php?id="234"');

내가 선택한 링크의 페이지 ID를 얻을 header('location: mobile/new.php?id=""');

에 전달하기 위해 추가하려면 어떤 코드

$_GET[''] 명령을 사용했지만 시도하지 못했습니다. 즉, 작동하지 않았습니다. header('location: mobile/new.php?id=<?php $_GET['id']; ?>');

답변

0

리디렉션 구문이 잘못되어 문제가 될 수 있습니다. URL 변수를 문자열 (예 : index.php?var="value")로 취급합니다. 적절한 구문은 문자열을 만들 때

header('Location: mobil/new.php?id=1234'); 

이 그런 다음 당신은 항상 보안상의 이유로 사용자의 입력을 확인해야

header("Location: mobil/new.php?id={$_GET['id']}"); 

할 수있을 것이다.

나는 $ _GET [ '']를 사용하여 시도

마지막 문장에서

명령을하지만 즉 헤더 작동하지 않았다 ('위치 : 모바일/new.php ID = <?php $_GET['id']; ?>'?)를;

당신이 이미 PHP에 들어갔을 때 당신이 문제였던 것입니다. 마지막 입구를 닫지 않은 상태에서 <?php을 사용할 필요가 없습니다. 또한 구문이 잘못되었지만 echo이 누락되었습니다.

관련 문제