returning to signup form

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • David

    returning to signup form

    hi

    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?

    cheers
    dave
  • Marcel

    #2
    Re: returning to signup form


    "David" <davidsobey@gma il.com> schreef in bericht
    news:f3f4c937.0 409140431.5a889 781@posting.goo gle.com...[color=blue]
    > hi
    >
    > 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?
    >
    > cheers
    > dave[/color]

    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("Locatio n: nextpage.php");
    exit;
    }

    }

    Marcel


    Comment

    • nice.guy.nige

      #3
      Re: returning to signup form

      While the city slept, David (davidsobey@gma il.com) feverishly typed...
      [color=blue]
      > hi[/color]

      Ay up,
      [color=blue]
      > 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?[/color]

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

      <html>
      <head>
      <!-- head stuff here -->
      </head>
      <body>

      <?php

      $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>Pleas e enter a value for Name</p>");
      }
      else {
      $defaultName = $name;
      }
      if($email == "") {
      print("<p>Pleas e enter a value for Email Address</p>");
      }
      else {
      $defaultEmail = $email;
      }
      }
      else {
      print("<p>Thank s for your input!</p>");
      // write the form contents to your database, or whatever
      }
      }

      if ((!isset($updat e)) || ($formError)) {
      ?>

      <form action = "thispage.php?u pdate=1" method="post">
      <p>Name: <input type="text" name="name" value="<?=$defa ultName?>"></p>
      <p>Email Address: <input type="text" name="email"
      value="<?=$defa ultEmail?>"></p>
      <input type = "submit" name="submit" value="Submit">
      </form>
      <?
      }
      ?>

      </body>
      </html>

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

      Hope that helps,
      Nige

      --
      Nigel Moss
      This is the personal website of Nigel Moss - Web and software developer, musician, photographer. It is home to my CV, portfolio, general info and more.

      Mail address not valid. nigel@DOG.nigen et.org.uk, take the DOG. out!
      In the land of the blind, the one-eyed man is very, very busy!


      Comment

      • David

        #4
        Re: returning to signup form

        think i get it now. cheers guys

        dave

        Comment

        Working...