Well, if you keen on separating business from presentation (which is usually a good practice), you can always do this:

<?php
 if (isset($_POST['action']))
{
  if (DoProcess($_POST))
 {
     PrintSuccess();
   }
 else
 {
    PrintFailure();
    PrintForm();
 }
}
?>

So you can call in fact the processing page, the real presentation can be in another PHP file, as well as the processing functions. Of course, instead of PrintForm() you can actually implant the real HTML code. And by the way, if you keep the form and the processing parts in one file, and create the form like this:
<FORM action="<?= $_SERVER['PHP_SELF'] ?>">

you can name your file as you want, it will work without rewriting the page.

SanTa

----- Original Message ----- From: "MEM" <tal...@gmail.com> To: "'Sándor Tamás (HostWare Kft.)'" <sandorta...@hostware.hu>; "'PHP-General List'" <php-general@lists.php.net>
Sent: Friday, April 24, 2009 3:03 PM
Subject: RE: [PHP] Self-Process php forms or not?


So, on your opinion, we can call that method, on some circumstances, a good
practice?

What about the moto: "let's separate business from presentation?"


Thanks once again,
Márcio


-----Original Message-----
From: Sándor Tamás (HostWare Kft.) [mailto:sandorta...@hostware.hu]
Sent: sexta-feira, 24 de Abril de 2009 13:53
To: 'PHP-General List'
Subject: Re: [PHP] Self-Process php forms or not?

I think the main advantage is that if something goes wrong processing
the
datas, you can show the form again without redirecting again.

And if you have to change the behavior of the page, you have to change
only
one file instead of two.

SanTa



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


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

Reply via email to