Re: header( 'refresh' ), form data, and IE
| From: | Dan | Date: | Tue, 24 Jul 2007 00:37:04 +0000 |
| Subject: | Re: header( 'refresh' ), form data, and IE | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-259406@lists.php.net to get a copy of this message | ||
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
}
header('REFRESH: 1; URL=http://www.somesite.com/action.php' . $description . $categoryid);
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.
- Dan
"Daniel Kasak" <dkasak@nusconsulting.com.au> wrote in message news:1185236298.22106.16.camel@dkasak.nusconsulting.com.au...
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: dkasak@nusconsulting.com.au website: http://www.nusconsulting.com.au