jeudi 7 novembre 2019

I want to make a secure link

i want to make a code generator link,like

www.website.com/register?code=29U3HTR3H219URH923UH419H94RH1298491U2HERUH1?plan_bought=LowReseller

in a functions file on php that is redirecting an user on that link.

$planned = htmlspecialchars($_GET["planbought"]);
// connect to database
$db = mysqli_connect('localhost', 'root', 'pass');
mysqli_select_db($db,"ronp");


function generateRandomString($length = 16)
{
    $pool = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';

    return substr(str_shuffle(str_repeat($pool, $length)), 0, $length);
}

$code_secure = generateRandomString(17);  // OR: generateRandomString(24)

$query = "INSERT INTO codes (code, expired, 'date', plan) 
                      VALUES('$code_secure', '0', date, '$planned')";
            mysqli_query($db, $query);

header('Location: register?code=', $code_secure);
?>

Process: After payment,paypal will redirect user on https://website.com/functions_generate-ak9esysgenthos.php?planbought=Low

That link will create a code in database,and will redirect user on https://website.com/register?code_secure=(code)

Now the problem is,i get redirected on "https://website.com/register?code=",not "https://website.com/register?code=(the code created in database,like 'J2498JT9UJ249UTJ293UJ59U123J9RU9U')"




Aucun commentaire:

Enregistrer un commentaire