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=a&var2=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: dkasak@xxxxxxxxxxxxxxxxxxxx
website: http://www.nusconsulting.com.au
.



Relevant Pages

  • Re: How do you figure out how much memory a class is using?
    ... > I just wrap them in an If statement and check the flag. ... In fact I normally encapsulate all access to Session, Viewstate, Cache, ... Session for the variable... ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Virtual HID mouse driver with multi-monitor
    ... you can createa new thread for each session and attach that thread to the new desktop ... there's a flag MOUSE_VIRTUAL_DESKTOP that is supposed to map the ... absolute coordinate onto the whole virtual desktop (instead of the ... values you need to send and tell the driver using an IOCTL. ...
    (microsoft.public.development.device.drivers)
  • Re: creating related record
    ... I suspect there's no reason to use globals for session-held values either -- just an old habit I haven't yet broken myself from. ... I find I don't have to reference session variables often but I do need them in a variety of places and it's easier to track it down from a list then to remember what I called it. ... Associate Member, FileMaker Solutions Alliance ...
    (comp.databases.filemaker)
  • Re: Track the users on line?
    ... It closes the session after the number of minutes specified in web.config ... A user login, update table flag to know that user has logged into the system. ... If he try again to log from a new browser, the check for the flag doesn't allow the access. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Track the users on line?
    ... But doesn't the session close the channel when the user close the browser? ... A user login, update table flag to know that user has logged into the system. ... If he try again to log from a new browser, the check for the flag doesn't allow the access. ...
    (microsoft.public.dotnet.framework.aspnet)