简体   繁体   中英

PHP getRandomURL generate random id

I want generate an random number behind my .php file. But i dont see any results.

$login = "login.php";

Heres the Code:

<?php
session_start();
include("config.php");


header('Location:' . $login . $urlext);

$urlext = getRandomURL();

function getRandomURL() {
        if (!isset($_SESSION['randomUrl'])) {
            $_SESSION['randomUrl'] =    '?assoc_handle=' .
                                                            substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, 30) . 
                                                            '&openid_claim=' .
                                                            substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, 20) .
                                                            '&identifier_select=' .
                                                            substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, 20) .
                                                            '&pape_max=' .
                                                            substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, 30);
            return $_SESSION['randomUrl'];
        } else {
            return $_SESSION['randomUrl'];
        }
    }


?>

The Page redirect to /login.php Location but dont generate an random number behind the file in the url. Any one an Idea? Or must i do it in an Session?

Put this line in your php file:

$urlext = getRandomURL();

before

header('Location:' . $login . $urlext);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM