Re: Self-Process php forms or not?

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

 



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" <talofo@xxxxxxxxx> To: "'Sándor Tamás (HostWare Kft.)'" <sandortamas@xxxxxxxxxxx>; "'PHP-General List'" <php-general@xxxxxxxxxxxxx>
Sent: Friday, April 24, 2009 3:03 PM
Subject: RE:  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:sandortamas@xxxxxxxxxxx]
Sent: sexta-feira, 24 de Abril de 2009 13:53
To: 'PHP-General List'
Subject: Re:  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


[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