Re: header( 'refresh' ), form data, and IE

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxxxxxxxx> wrote in message news:1185236298.22106.16.camel@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
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@xxxxxxxxxxxxxxxxxxxx
website: http://www.nusconsulting.com.au

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux