Results 1 to 34 of 34

Thread: [RESOLVED] Verifying before accessing form?

Threaded View

  1. #25

    Thread Starter
    Addicted Member
    Join Date
    May 2009
    Posts
    166

    Re: Verifying before accessing form?

    Ok, either you show the form again or you continue and the form was submitted successfully. I think what I wasn't understanding is when the error messages get displayed when the fields aren't filled out properly? I've got the error messages stored in the $message variables. If no messages the form is submitted and you get the successs message otherwise the form is re-displayed. So would the error message appear at the top of the page and then the form underneath?

    When I started I tried to put the form before the if statments checking for values. It just seeme like I was trying to check for something that didn't exist yet.

    The way it is now. When in error the form is redisplayed but without filling in the fields with the previous values. How do you retain the values from the previous form to fill the values back in on the new form?

    I tried it like this:

    PHP Code:
    $firstName mysql_real_escape_string($_POST['firstName']); 
    to store the field information.

    and then when the form re-displays I tried to display values:

    PHP Code:
      <label for="firstName">First name:<span>*</span></label>
                <input type="text"  id="firstName" value="<?PHP echo $firstName?>" name="firstName" tabindex="1" />

    I tried to combine the auth.php where the session was started the form.php and combine the two files into one. I've also added the captcha. It works perfectly, the way you showed me but I'm kind of lost with the error messages. If there is an error we just display the form again but the user doesn't know what they did wrong.

    When you get to the statement:

    PHP Code:
     if($showform): 
    This is where I should have the my error statement and then put everything in a brackets, maybe starting like this:

    PHP Code:
    <?PHP


     
    if($showform) {

    echo 
    $message

    ?>

    <html>
       <head>
           </head>
     <body>
       <h1>Form Project</h1>
        <p><span>*</span>Indicates required information</p>
           <form name='information' action ='form.php' method='POST'>
            <fieldset id='address'>
              <legend>Contact</legend>
              <ul class="form">
              <li>
                <label for="firstName">First name:<span>*</span></label>
                <input type="text"  id="firstName" value="<?PHP echo $firstName?>" name="firstName" tabindex="1" />
              </li>
    ...................
    ...................
    I'm sure your thoroughly confused about what I just posted?
    Last edited by Blue1974; May 13th, 2010 at 05:43 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width