|
Posted by Dikkie Dik on 11/27/56 11:28
Thejo wrote:
> Hi all,
>
> I started programming in PHP recently and have a query about empty
> $_POST arrays. I can see two scenarios when this could happen.
>
> 1. When some tries to directly load the page to which data is being
> posted (for example, opening www.foo.com/xyz.php directly when a form
> action is xyz.php)
> 2. When the user clicks the submit button without entering anything.
>
Then (if method=post), the submit button itself is ported (it has a name
and a value).
> I am aware that Javascript validation can take care of the second case,
> but it's unreliable. What is the accepted way of handling the above
> situations on the server side?
> Do I just reload the calling page if the array is empty?
>
> Thanks,
> Thejo
>
It is not uncommon to omit the action attribute on the form of a PHP
webpage. This means that the same page is used for displaying of the
form AND for processing the results. This can be handy for continuous
adding or giving the user a second change to correct the data posted.
Off course, an if-statement gives you the power to have the same page
behave totally different depending on what was posted.
Best regards
[Back to original message]
|