BaeFell
BaeFell

Reputation: 650

Generate a custom number, Save it to a text file with the number as the name and then redirect to it

I'm working on a program that has a premium section to it, but it must be bought through a website, so what I need is that after the PayPal Purchase (If you can include the code that even better) you get sent to a page that generates a custom number and then saves it to a text file with "Your custom number is: x" then the viewer gets redirected to it, the file must be called the number for the program to function with it

I have some code:

<?php
$x=rand(15455, 15875868);
$content = "$x";
$fp = fopen($_SERVER['DOCUMENT_ROOT'] . "/" + $x + ".txt","wb");
fwrite($fp,$content);

fclose($fp);
?>

I just can't get it so that the user is redirect to the file once done, but also to make it so that people can't refresh/go back and get a new one....

If I have made this question unclear of what I need help with, please reply! Thanks! :D

Upvotes: 0

Views: 78

Answers (1)

Jompper
Jompper

Reputation: 1402

Add this to end of your script.

header("location: /{$x}.txt");

Upvotes: 1

Related Questions