Re: Direct to new page without headers



amygdala wrote:
amygdala schreef:
sheldonlg schreef:
amygdala wrote:
sheldonlg schreef:

<snip>


Before you output any content, handle all necessary business logic.
And why spread logic of one form over multiple scripts? You could easily do something basic like this:

Frankly, I prefer multiple scripts. It makes the logic much easier. Thus I will have a.php and a_submit.php where a.php is what is presented to the user (with pre-processing) and a_submit.php never appears to the user.

Well, I guess we have to agree to disagree then. I'ld much rather have all logic of one form, including submission handling in one place. Moreover, theoretically, with you're example, users could request the file a_submit.php, if they knew of it's existance (could occur if something went wrong during processing in a_submit.php and the execution halted there)

But then again, this was a very basic example. Nowadays I use a MVC structure where controller class methods process requests.

And to me it would make no sense to have a URL like:

http://www.example.com/form/

and

http://www.example.com/form-success/

or something like that. Because I concider the resource to basically be the same. Only the type of requests differ.


To add to that: what if submission in a_submit.php didn't succeed? You'ld have to redirect back to a.php again to display errors. Keep all errors in a session to display them in a.php. Pretty cumbersome if you ask me.

The methodology that I have developed over time that has worked best for me is to have a template file (for uniformity of appearance between pages). This file has in its body a php include specified by a php variable. I also have a director page that so my URL always looks like:

http://www.abc.com/director.php?page=foo&msg=bar

The director has a switch statement that defines a preprocessing script (foo_process.php) and the html variable (foo.php) to be used in the template file. The preprocessor is included and then the template (which includes the the script defined above). In the template I have a block that will output the content of $msg if it exists.

So, I really have three scripts per page. One is the prepocessor, one is the html content, and the third is the postprocessor. The preprocessor and the postprocessor also do access checking to prevent unauthorized access via a separate include file.

.



Relevant Pages

  • Multiple scripts on same HTML page
    ... I know I can have multiple scripts on one HTML page (at least I think I know ... one solid lesson: Just because it works one way, ...
    (comp.lang.javascript)
  • Re: /etc/rc.boot
    ... > Please don't make me write init.d scripts for every single line ... and add it into the boot sequence using ... then you need multiple scripts, but nothing is stopping you from ... "Theoretical politics is interesting. ...
    (Debian-User)
  • Mulitple shell scripts accessing a single log file
    ... A single log file, which is been written simultaneously, ... Would there be any problems if multiple scripts try writing to ...
    (comp.unix.shell)
  • Re: Running multiple login scripts
    ... >i was wondering if it was possible to run multiple scripts when putting them ... >into the Profile tab of a user. ... Prev by Date: ...
    (microsoft.public.win2000.active_directory)