Seems like you're getting confused about output verses php code.  Let's say
you have a file called "form.php"...

it submits to itself, checking the submitted data.  if the form input is
good, you want to do "stuff", then redirect them to a thanks page.  if it
isn't, you want to send them back to try again.

Easy.

form.php
---
<?
if(!isset($action))
    {
    ?>
    <HTML>
    <?
    if($problem)
        {
        echo "there was a problem with your entry, please try again";
        }
    ?>
    <!-- form here -->
    </HTML>
    <?
    }
else
    {
    if($action == "validate")
        {
        //
        // check form input
        //
        if($input == "valid")
            {
            // insert stuff into your data base, or do whatever
            header("Location: form.php?action=thanks");
            // no output to screen
            }
        else   
            {
            header("Location: form.php?problem=1");
            // they're sent back to the form,
            // and told there was a problem
            // no output to screen
            }
        }
    elseif($action == "thanks")
        {
        ?>
        <HTML>
        <BODY>
        <FONT>Thanks!</FONT>
        </BODY>
        </HTML>
        <?
        }
    }
?>
---

So, obviously it needs massaging, and none of the code is tested, but it's
the same way I do my forms.

It'd be better if you told them where they went wrong on the form, and there
are lots of ways to streamline the code and make it more modular, but this
should be enough to give you an idea about how you can use the header(), and
at what point you've sent "output" to the browser.


Justin French
--------------------
Creative Director
http://Indent.com.au
--------------------


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

Reply via email to