/    Sign up×
Community /Pin to ProfileBookmark

Don’t understand file generation.

So, basically what my problem is, is that I don’t understand file generation at all, I’m also (Currently) using shared hosting, (Planning on switching to dedicated hosting later, if this works out) so I can’t install any PHP Libraries.

In a nutshell my script does a bunch of database checks, and random generation after the purchase of a product to create a unique software key that is to be stored in an XML file, to be used with my Server application that I’m getting ready to market.

I’m not a very experienced web-developer by any means, but I can usually get by, this however takes the cake on the most annoying thing I’ve ever dealt with.

The XML File contains the following information.

[code]<Account Username=”?” Password=”?” Key=”?”></Account>[/code]

After doing hours and hours of research I found a method that was supposed to generate and make the user download the file, but it doesn’t work:

[CODE]
header(‘Content-Disposition: attachment;filename=License.xml’);
header(‘Content-Type: text/xml’);
$dom = new DOMDocument();
$xml = $dom->createTextNode(‘<Account Username=”‘.$fuser.'” Password=”‘.$fpass.'” Key=”‘.$softwareKey.'”></Account>’);
$xml = $dom->appendChild($xml);
echo $dom->saveXML();
[/CODE]

I would assume it doesn’t work because I have content on the website, so what this does it it downloads the website (in .HTML format) and saves it as License.XML and downloads it to the users computer. They don’t need my websites source code! They need the String i passed into $dom!

I’m looking for a method to do the following(Atleast one of them):

[LIST]

  • [*]

    Generate the file and send it as an e-mail


  • [*]

    Generate the file and display a link for the user to click on to download the file.


  • [*]

    Generate the file and automatically download it.


  • [/LIST]

    All of this needs to be done while the website’s page can be viewed, because there’s a bunch of information about how to use the License, where it belongs, and how to configure their application to parse it.

    to post a comment
    PHP

    1 Comments(s)

    Copy linkTweet thisAlerts:
    @NogDogNov 02.2014 — The code you showed will need to be put into a separate "file server" script (separate from the script that is displaying the page you want shown). Therefore you might want to use session variables to hold the values needed for the XML generation, then the main script will display a link to the file-server script. Also, make sure nothing -- not even white-space -- gets output before those header() calls in the file-server script.
    ×

    Success!

    Help @CTucker1327 spread the word by sharing this article on Twitter...

    Tweet This
    Sign in
    Forgot password?
    Sign in with TwitchSign in with GithubCreate Account
    about: ({
    version: 0.1.9 BETA 5.19,
    whats_new: community page,
    up_next: more Davinci•003 tasks,
    coming_soon: events calendar,
    social: @webDeveloperHQ
    });

    legal: ({
    terms: of use,
    privacy: policy
    });
    changelog: (
    version: 0.1.9,
    notes: added community page

    version: 0.1.8,
    notes: added Davinci•003

    version: 0.1.7,
    notes: upvote answers to bounties

    version: 0.1.6,
    notes: article editor refresh
    )...
    recent_tips: (
    tipper: @AriseFacilitySolutions09,
    tipped: article
    amount: 1000 SATS,

    tipper: @Yussuf4331,
    tipped: article
    amount: 1000 SATS,

    tipper: @darkwebsites540,
    tipped: article
    amount: 10 SATS,
    )...