Re: Re: Returning response includes HTML form data

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

 



Maciek Sokolewicz wrote:
Edward Diener wrote:
Benjamin Hawkes-Lewis wrote:
Edward Diener wrote:
Does not the script 'exit' when the PHP code reaches the ending
'?>' tag ?

Not exactly. PHP processes the remainder of the file too, it just doesn't find any PHP code to execute therein. It does find some text to output, and it outputs it. That text happens to be a form.

Now I see. Just like in normal HTML processing a request to a URL which is an HTML page, sends the HTML markup back to the client. My PHP page is a normal HTML page with PHP processing embedded in it. Hit me on the head and wake me up <g>.

How does one stop PHP from outputting data in a PHP file outside of the PHP tags ? Hopefully there is a technique for that. can I just 'exit' in the PHP processing code in order to do that ? It seems that should work and I will try it.
yes, you can do that.

In my case I am using the form data just to process the request and not to be sent back to the client, especially as a form itself is not a complete HTML page.
You could also conditially display it, like so:

<?php
if(isset($_GET['something']) && $_GET['something'] == 'something else') {
   // do something with the data
} else {
   ?>
   <form>...</form>
<?php
}
?>

or perhaps like so, by setting a flag:
<?php
$processed = false;
if(isset($_GET['something']) && $_GET['something'] == 'something else') {
   // do something with the data
   $processed = true;
}

// lots of stuff going on here

if($processed === false) {
?>
   <form>...</form>
<?php
}
?>

OK, thanks ! In my case I never want to send the form back to the client since it exists only to handle an HTTP POST on the server side.

--
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