Re: [PHP] Re: header( 'refresh' ), form data, and IE
On Tue, 2007-07-24 at 08:13 -0400, Daniel Brown wrote: Hello, Dans! Dan K., is there any reason the validation can't reside within the same script as the form, then forward on success? A very simple example: ? if($_POST) { // Check to ensure that your variables are all correct, // then use header(Location: successful-target.php?var1=avar2=b); // And then, on forwarding, remember to exit; } ? FORM METHOD=POST ACTION=?=$_SERVER['PHP_SELF'];? INPUT TYPE=TEXT NAME=var1 VALUE=?=$_POST['var1'];?BR / INPUT TYPE=TEXT NAME=var2 VALUE=?=$_POST['var2'];?BR / INPUT TYPE=SUBMIT VALUE=GO! /FORM Since the user will start with a blank form, and the $_POST values won't already be set, the values in the form will be blank on the initial page load, but for unsuccessful attempts, they'll be populated with the correct data. ~ Dan^[3] I've completely changed the way I was doing this now. Initially I implemented lots of checks for NULL values, as Dan[2] recommended, and this worked well apart from in the case of text areas. These broke things completely. I've now decided to shove all form data into session globals, and just refresh with a 'load_previous' flag in the URL. I my form constructor sees this flag, it populates things from session globals. Otherwise it resets the session globals with defaults. This seems to be the best solution ( ie the only one that's worked completely so far ). Thank you, both of you. Long live Dans! -- Daniel Kasak IT Developer NUS Consulting Group Level 5, 77 Pacific Highway North Sydney, NSW, Australia 2060 T: (+61) 2 9922-7676 / F: (+61) 2 9922 7989 email: [EMAIL PROTECTED] website: http://www.nusconsulting.com.au -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] header( 'refresh' ), form data, and IE
Greetings. I have a data entry form that checks for valid input. If something's wrong, it should refresh back to the data entry form, and pass the existing fields back to this form, so the user doesn't have to enter everything again. This is working perfectly in Firefox. It doesn't work at all in Internet Explorer ( 6 ). I can do *simple* refresh operations, such as: header( 'REFRESH: 1; URL=http://www.google.com' ); If I do more complex things, such as append the form data to the URL, it breaks when a field is blank. For example: header( 'REFRESH: 1; URL=http://www.somesite.com/action.php' . '?description=' . $_POST['description'] . 'categoryid=' . $_POST['categoryid'] ); In the above, categoryid is always OK, because it comes from a combo ( select, whatever ), and at the least it has a default value of 0. However if nothing was entered in the 'description' field, I get a URL: http://www.somesite.com/action.php?description=categoryid=2 Firefox can handle the above perfectly. IE doesn't like the NULL description bit. What's the best way around this? -- Daniel Kasak IT Developer NUS Consulting Group Level 5, 77 Pacific Highway North Sydney, NSW, Australia 2060 T: (+61) 2 9922-7676 / F: (+61) 2 9922 7989 email: [EMAIL PROTECTED] website: http://www.nusconsulting.com.au -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: header( 'refresh' ), form data, and IE
Thanks for the response Dan. Us Dans have to stick together :) On Mon, 2007-07-23 at 17:37 -0700, Dan wrote: Then validate the field obviously! $description = ; $categoryid = ; if(isset($_POST['description'])) $description = ?description=$_POST['description']; if(isset($_POST['categoryid'])) { if($description != ) $categoryid = ; else $categoryid = ?; // if a description has been entered you'll need an symbol otherwise a ? $category .= categoryid=$_POST['categoryid']; // append category to itself with the posted info } H. Yeah I thought it would come to that. I was hoping for a quick nasty fix. I didn't test this it's just off the top of my head, also you should sanitize the input before you do anythign with it really, but that's another issue. Also this is really something that you should be doing with ajax rather than having the page reloading, and passing variables back, etc. This is the EXACT purpose that Ajax as made for, validation of info. Check out XAJAX it's very simple to use but powerfull when you need it. I will try to make some time for investigating ajax. I'm mostly developing in Perl, and doing nice GUI stuff ( ie no web stuff - this is a once-off maintenance thing ), so I'll a little out of my comfort zone ... Thanks again for your help. -- Daniel Kasak IT Developer NUS Consulting Group Level 5, 77 Pacific Highway North Sydney, NSW, Australia 2060 T: (+61) 2 9922-7676 / F: (+61) 2 9922 7989 email: [EMAIL PROTECTED] website: http://www.nusconsulting.com.au -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Streaming download to IE doesn't work
On Wed, 2007-05-30 at 13:40 -0500, Richard Lynch wrote: On Tue, May 29, 2007 6:37 pm, Daniel Kasak wrote: Actually, that blog had absolutely nothing to do with my problem ( thanks for RTFP!). Not only that, but the recommendation that I construct URLs: http://address.com/script/thing=2/this=3/that=4/download.txt is patently ridiculous. Why? It's excessively complex for no actual benefit. It means you have to have extra code to 'explode' out the various parts of the URL. Even after reading your description of the code that handles this, it was non-obvious what it was for. If I returned to this 2 years later ( or God forbid, someone else had to look at it ), they wouldn't have a clue what it was doing, or why. But also, as I noted, this 'solution' is to a different problem - the problem of IE not naming downloads properly. IE names them properly for me ... it just doesn't download them ( if over SSL ). -- Daniel Kasak IT Developer NUS Consulting Group Level 5, 77 Pacific Highway North Sydney, NSW, Australia 2060 T: (+61) 2 9922-7676 / F: (+61) 2 9922 7989 email: [EMAIL PROTECTED] website: http://www.nusconsulting.com.au -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Streaming download to IE doesn't work
Sorry ... forgot to comment on this ... On Wed, 2007-05-30 at 13:40 -0500, Richard Lynch wrote: ... in particular, adding: header(Cache-control: private); header(Pragma: public); fixed things perfectly. Also note that things worked perfectly with normal http access from the start; this is required for streaming downloads to IE over *https* I highly recommend you now re-test your application in every browser, every minor version, every release you care about, on every OS major.minor you care about. Yes I realise this. When I originally discovered the problem ( after developing the app and extensively testing with firefox ), my first impulse was to get the client to use firefox. The response was that the app would be used by 2 of *their* clients, and they insist on using IE6. So based on this, I tested made things work with IE6 and the latest service packs available via Microsoft Update. I have absolutely no interest in supporting every single version of every single browser, at least not for the money I'm being paid, and especially since I've already been told that the app only needs to support IE6 ( and it also already supports firefox ). -- Daniel Kasak IT Developer NUS Consulting Group Level 5, 77 Pacific Highway North Sydney, NSW, Australia 2060 T: (+61) 2 9922-7676 / F: (+61) 2 9922 7989 email: [EMAIL PROTECTED] website: http://www.nusconsulting.com.au -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Streaming download to IE doesn't work
On Tue, 2007-05-29 at 13:52 +0200, Jochem Maas wrote: Daniel Kasak wrote: Hi all. Who knows WTF is wrong and how I can work around it? without getting into the holywar of download headers, here is one mans's take/solution: http://richardlynch.blogspot.com/2006_06_01_archive.html it should contain enough to help you out. PS. you might recognize the name from the list PPS. if you have STFA you would have have found this already, this download problem comes up regularly. Actually, that blog had absolutely nothing to do with my problem ( thanks for RTFP!). Not only that, but the recommendation that I construct URLs: http://address.com/script/thing=2/this=3/that=4/download.txt is patently ridiculous. Anyway, for people who will stumble across this bug in the future, check out: http://terra.di.fct.unl.pt/docs/php/function.session-cache-limiter.php.htm ... in particular, adding: header(Cache-control: private); header(Pragma: public); fixed things perfectly. Also note that things worked perfectly with normal http access from the start; this is required for streaming downloads to IE over *https* -- Daniel Kasak IT Developer NUS Consulting Group Level 5, 77 Pacific Highway North Sydney, NSW, Australia 2060 T: (+61) 2 9922-7676 / F: (+61) 2 9922 7989 email: [EMAIL PROTECTED] website: http://www.nusconsulting.com.au -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Streaming download to IE doesn't work
Hi all. I'm streaming a file ( location of which is to be hidden from clients, hence the need to stream ). Basically I'm doing: --- session_start(); // some authentication stuff and figuring out the path goes here // ... // ... $source = /accounts_reports/ . $_GET['id'] . .bin; header( Content-Disposition: attachment; filename=\ . $orig . \ ); header( Content-Length: .filesize( $source ) ); header( Content-Type: application/octet-stream ); header( Pragma: no-cache ); header( Expires: 0 ); readfile( $source ); --- This works *perfectly* with firefox. It doesn't work at all with Internet Explorer. Also ( not sure if this matters or not ), the site is accessed via https ONLY. When I click the link to my download php script, I get a dialog asking if I want to open or save the file, and then whnatever I click, I get: Internet Explorer cannot download download.php?id=32 from IP_ADDRESS. Internet Explorer was not able to open this Internet site. The requested site is either unavailable or cannot be found. Please try again later. However, a quick check of apache's ssl access log shows that IE did in fact 'find' the site. Also, IE is producing the download dialog, which suggests that it's 'found' the download.php script fine. Now, before I get a litany of 'just use firefox then' responses, rest assured that I would take this approach if I could, but the site is for a customer, and they are in turn doing it for their customers, and this just isn't going to fly. It MUST work with IE. Who knows WTF is wrong and how I can work around it? -- Daniel Kasak IT Developer NUS Consulting Group Level 5, 77 Pacific Highway North Sydney, NSW, Australia 2060 T: (+61) 2 9922-7676 / F: (+61) 2 9922 7989 email: [EMAIL PROTECTED] website: http://www.nusconsulting.com.au -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php