0

次のようなURL設定があります

mysite.com/QR?id=12345

id は数値になります。この URL を参照し、id 値を取得して、ページを別の URL にリダイレクトできるようにしたいと考えています。

PHPでこれを行うことはできますか?ID は、DB の ID にも対応します。

編集:元の質問を修正してください。私が持っているのは、ID が任意の番号である、存在しないページへの URL です。その URL を参照して id 値を抽出し、DB に対応する値を持つ ID に基づいてコンテンツを表示する新しいページにリダイレクトする方法が必要です。

4

3 に答える 3

3
// First check if it exists
if (isset($_GET['id']))
{
    $id = someSecurityFunction($_GET['id']);        

    // Check what the value is of ID
    switch ($id)
    {
        case '12345':
            header("Location: website.com?...");
            exit();
        case '67890':
            header("Location: website.com?...");
            exit();
        default:
            echo "No corresponding ID value found...";
            break;
    }

    // Or just redirect to another page and handle there your ID existence thing
    // by omitting the switch-case and redirect at once
    // header("Location: website.com?id=$id");
}
else
{
    echo "No ID found in querystring...";
}

これであなたの質問に答えられるでしょうか

于 2013-11-11T15:20:44.153 に答える
1
if(isset($_GET['id']) == '12345'){
    header('Location: example.com');
}

こんな感じかな?

于 2013-11-11T15:16:31.783 に答える