Hi-
I'm creating a Registration form with database connections. I've done PHP forms, DB connections, cookies, etc (nothing I would call advanced) before.

I have the registration page, and when you hit submit it goes to 'do_registration.php'. My question is, while in the 'do_registration' page, and I hit a "bad email" or "username taken", I want it to go back to the registration page, display an error message based on what was wrong. How do I pass the variables for each of those fields back to the registration page and then when they correct it, hit submit, back to the do_registration.

If I'm not making sense, let me know. Thanks in advance!

    It might be easier to combine your two files into one and post back to itself, then you don't have to worry about passing the values back to the first page.

      Put the HTML form and the PHP code in the same page, and set the action of your FORM to $PHP_SELF.

        Something like this ...

        <?php
        
        if (something isn't typed in properly) {
        $error = 1;
        }
        
        if ($submitted == "yes" && $errors == "0") {
        // do insert
        } else  {
        // create error report and show form again
        ?>
        
        <FORM METHOD="post" ACTION="<?=$_SERVER_['PHP_SELF']; ?>">
        <INPUT TYPE=hidden NAME="submitted" VALUE="yes">
        <INPUT TYPE=text NAME="field1" VALUE="<?=$_POST['field1']; ?>">
        <INPUT TYPE=submit>
        </FORM>
        
        <?
        }
        ?>
        
          Write a Reply...