www.webdeveloper.com
Recent Articles
  • Finding Slow Running Queries in ASE 15
  • A More Advanced Pie Chart for Analysis Services Data
  • Adobe AIR Programming Unleashed: Working with Windows
  • Performance Testing SQL Server 2008's Change Data Capture Functionality
  • The ABC's of PHP: Introduction to PHP
  • How to Migrate from BasicFiles to SecureFiles Storage
  • Why the Twitter Haters Are Wrong
  • User Personalization with PHP: Beginning the Application
  • Whats in an Oracle Schema?
  • Lighting Enhancement in Photoshop
  •  

    Go Back   WebDeveloper.com > Server-Side Development > PHP

    PHP Discussion and technical support for using and deploying PHP based websites.

    Reply
     
    Thread Tools Search this Thread Rate Thread Display Modes
      #1  
    Old 05-11-2007, 09:34 PM
    focus310 focus310 is offline
    Registered User
     
    Join Date: Feb 2006
    Posts: 193
    resolved [RESOLVED] Validating form fields

    Hello:

    I'm trying to valide fields in a form which has many pages and each page is its own script. When I test my form by leaving the field blank, I should receive an error message stating Please enter your name. When I click Submit, I do not receive that message after leaving the field blank. I'm not sure if it's because I'm posting to another script. I can't understand why that should matter.

    I included the code for the first and second page of the form. For easier reading, I am only showing one form field. In the second page of the form, I didn't include any of the form fields since page 2 shouldn't appear until all the fields on page 1 are filled in.

    I hope someone can help me out. Thank you in advance.

    This is the first page of the form.
    Code:
    <?php 
    
    include('header_app.html');
    if (isset($_POST['submitted'])) {
      $errors = array();
    
      //validate form data  
      
       if (empty($_POST['complete'])) {
        $errors[] = 'Please enter your name.';
       } else {
        $_SESSION['complete'] = escape_data($_POST['complete']);
       }
    
    }
    
    ?>
    
    <form action="app_admission_pg2.php" method="post">
    <table class="apptable">
    <tr><td class="a"><b>Application Completed by:</b></td><td class="b"><input type="text" name="complete" size="25" value="<?php if (isset($_SESSION['complete'])) echo $_SESSION['complete']; ?>"></td></tr>
    </table>
    <input type="submit" name="btnSubmit" id="btnSubmit" value="Page 2 >>" class="btn" >
    <input type="hidden" name="submitted" value="TRUE" />
    </form>
    ===============================
    This is the second page of the form.
    Code:
    <?php
    include('header_app.html');
    $_SESSION['complete']=$_POST['complete'];
    <form action="app_admission_pg3.php"  method="post" >
    <This section will have the next batch of questions.>
    </form>
    Reply With Quote
      #2  
    Old 05-12-2007, 11:58 AM
    kurniawan kurniawan is offline
    Registered User
     
    Join Date: May 2007
    Location: Tamalanrea
    Posts: 31
    Sorry, I am confusing. Is this what you mean?

    app_admission_pg2.php -> the second page of the form

    or this?

    app_admission_pg2.php -> the first page of the form


    IF app_admission_pg2.php -> the first page of the form
    then, try to check did you put session_start() in the beginning of the files.

    -----------------------------------------------
    http://anaknegri.com http://pajaknenkin.com http://arifkurniawan.net
    http://ppi-kansai.net http://kti2007.ppi-kansai.net

    Last edited by kurniawan; 05-12-2007 at 12:01 PM.
    Reply With Quote
    Reply

    Bookmarks


    Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
     
    Thread Tools Search this Thread
    Search this Thread:

    Advanced Search
    Display Modes Rate This Thread
    Rate This Thread:

    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is Off
    HTML code is Off
    Forum Jump


    All times are GMT -5. The time now is 12:04 PM.



    Acceptable Use Policy


    The Network for Technology Professionals

    Search:

    About Internet.com

    Legal Notices, Licensing, Permissions, Privacy Policy.
    Advertise | Newsletters | E-mail Offers

    Powered by vBulletin® Version 3.7.3
    Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.