Use of Global Variable When Exporting / Downloading Content

Posted on 2011-05-02
Last Modified: 2012-05-11
Within an 'if' statement, I'm defining a variable that I'd like to be global. When I then export to text file for download, I'd like to use that variable to define the filename.

Not sure how to get this to work. Any assistance would be appreciated.

Here is some excerpt from what I currently have:

if( isset($_REQUEST['action']) && ( strval($_REQUEST['action']) == 'export') )      {
      header("Content-Type: application/txt");
      header("Content-Disposition: attachment; filename=$nameOfFile.xls");

if( $action != "export") {
      global $nameOfFile = "test.txt");
      ?><a href='?action=export'>Export</a><?php

if( $action == "export") {
      echo "This is just a test";
Question by:deharvy
    1 Comment
    LVL 76

    Accepted Solution

    What do you mean, are you trying to maintain unique filenames?
    YOu can either store it in a database or use session.

    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    Join & Write a Comment

    In tuning file systems on the Solaris Operating System, changing some parameters of a file system usually destroys the data on it. For instance, changing the cache segment block size in the volume of a T3 requires that you delete the existing volu…
    A metadevice consists of one or more devices (slices). It can be expanded by adding slices. Then, it can be grown to fill a larger space while the file system is in use. However, not all UNIX file systems (UFS) can be expanded this way. The conca…
    Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
    This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    23 Experts available now in Live!

    Get 1:1 Help Now