Page 1 of 1

Problem with downloading content from Header.

Posted: Mon Apr 02, 2007 4:12 am
by Tommy1402
feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


Hi I'm using MySQL, 
in my site , I added a data exporter facility to enable Admin to retrieve new data from database.
In my table there's a field called OLD, with type: ENUM. 0->false, and 1->true.

The logic is simple:
1. Admin opens the page, and he will see all new data (where OLD = 0)
2. Admin press RETRIEVE button, then he will be able to download all new data in the form of file [dot]SQL.
3. After he press SAVE button, the download begins and the data with OLD = 0 is automatically changed to OLD = 1.

The SQL file only consist of some INSERT commands (based on how much the new data).

I use HEADER to make the downloading procedure.

My problem is, when the Admin press RETRIEVE and press Cancel instead of SAVE, the OLD value of each new data is still changed into 1 ?

My question, how to handle a Header control so that I'm able to access whether user press SAVE or CANCEL ?

here the code: (btw, I use Zend Code)

Code: Select all

//$contents = the fetched data
$file_name = "warranty registration.sql";
$this->_response->setHeader('Content-Type','text/sql');
$this->_response->setHeader('Content-Disposition',"attachment; filename=$file_name");
$this->_response->setBody($contents);
Thanks for any helps!


feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Mon Apr 02, 2007 8:26 am
by feyd
You have no real way of knowing whether someone chose to save the information or not.

The only thing I can suggest is allowing them to choose when to mark the records as read.

There's potential for an HTTP multi-part push here, possibly. Not sure about that though.

Posted: Mon Apr 02, 2007 8:46 pm
by Tommy1402
Thanks for the suggestion.