returning to signup form

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

i have a basic signup POST form, with php on the same page. how do i
return to this page with all the entries still present, yet with a
message at the top, for when the user enters one invalid entry?


Re: returning to signup form

While the city slept, David ( feverishly typed...

Quoted text here. Click to load it

Ay up,

If you are posting the results to the page, then write them into the default
values for the input elements. Something like;

<!-- head stuff here -->


$defaultName = "Enter your name here"
$defaultEmail = "Enter your email address here"
$formError = false;

if($_POST['update'] == 1) {
    $name = $_POST['name'];
    $email = $_POST['email'];
    if(($name == "") || ($email == "")) {
        $formError = true;
        print("<p>Error on form.</p>");
        if($name == "") {
            print("<p>Please enter a value for Name</p>");
        else {
            $defaultName = $name;
        if($email == "") {
            print("<p>Please enter a value for Email Address</p>");
        else {
            $defaultEmail = $email;
    else {
        print("<p>Thanks for your input!</p>");
        //    write the form contents to your database, or whatever

if ((!isset($update)) || ($formError)) {

<form action = "thispage.php?update=1" method="post">
<p>Name: <input type="text" name="name" value="<?=$defaultName?>"></p>
<p>Email Address: <input type="text" name="email"
<input type = "submit" name="submit" value="Submit">


.... Note: This is straight off the top of my head! Not tested or anything!

Hope that helps,

Nigel Moss
Mail address not valid., take the DOG. out!
In the land of the blind, the one-eyed man is very, very busy!

Re: returning to signup form

think i get it now. cheers guys


Re: returning to signup form

Quoted text here. Click to load it

I consider you will write to a database in the same php page and then
redirect to another page

Put this in the top of your page:

if($Submit) { // Submit is the name of your submit button

    if(!$name || !$street) { # if for example name or street not filled in
        # generate errormessage
        if(!$name) {$err .= "Name not filled in";}
        if(!$street) {$err .= "Street not filled in";}
    } else {

          # alle input ok, here you can put your sql queries to interact
with the database

          header("Location: nextpage.php");



Site Timeline