So I am making a script where I want to learn how to limit use on one domain, but I need to modify the script before the download. My question is, I want to take a $_GET variable filled out by the user of their website. Customize a script with file_put_contents or something, and then download the modified script.. How would I go about this? Does it require Javascript and PHP, or just Javascript? I’m not sure how to go about it. An example of modifying a download can be found here
Share
So, if I understood correctly, a user fill some form with a var (lets call it $var) and clicks the form’s submit button to download a file (lets call it ‘myscript.php’).
You want to edit ‘myscript.php’ and put the $var inside that script before the user downloads it. Is this assumption correct?
For that you need to prepare your script beforehand by placing a placeholder somewhere and then, before the user downloads the file, you change the placeholder for the intended block of code. Alternatively you can replace the first
<?phptag for your code, if that’s relevant.Mini Example:
myscript1.php
Code called by form:
Here’s a more complete (and complex) example…
myscript2.php
Download script (called by the form)
validation function example: