+ Post New Thread
Results 1 to 9 of 9
Web Development Thread, validating php forms in Coding and Web Development; Hi all,i need help with validating form..I got 3 php files.How do i show the error messages beside the text..Here ...
  1. #1

    Join Date
    Feb 2009
    Location
    Indonesia
    Posts
    18
    Thank Post
    3
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    validating php forms

    Hi all,i need help with validating form..I got 3 php files.How do i show the error messages beside the text..Here are the codes

    output_fns.php
    Code:
    <?php
    function do_kepala($title){
    ?>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
    "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
    <title><?php echo $title ?></title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <link rel="stylesheet" href="include/style.css" type="text/css">
    </head>
    <body>
    <?php
    };
    function do_body()
    {
    ?>
    
    <br>
    <?php
    };
    function do_footer()
    {
    ?>
    tes 1234   
    </body>
    </html>
    <?php
    };
    function display_login_form()
    {
    ?>
    <div id="stylized" class="myform">
      <form id="form1" name="form1" method="post" action="reg.php">
        <fieldset>
        <legend >Data keanggotaan</legend>
        <br>
        <label>Email
            <span class="small">Become your id</span>
        </label>
        <input type="text" name="email" id="email" />
        <label>Password
            <span class="small">6-12 karakter</span>
        </label>
        <input type="password" name="pwd1" id="password" />
        <div class="spacer"></div>
        <label>Ulangi Password
            <span class="small">6-12 karakter</span>
        </label>
        <input type="password" name="pwd2" id="password" />
        <div class="spacer"></div>
        </fieldset>
        <fieldset>
        <legend>Personal data</legend>
        <br>
        <label>Name
        <span class="small">Your full name</span>
        </label>
        <input type="text" name="nama" id="nama"/>
        <div class="spacer"></div>
        <label for="tgl">Birthday date
        <span class="small">dd/mm/yyyy</span>
        </label>
        <select name="tgl" id="tgl">
            <option value="1" selected="selected">1</option>
            <option value="2">2</option>
            <option value="3">3</option>
            <option value="4">4</option>
            <option value="5">5</option>
            <option value="6">6</option>
            <option value="7">7</option>
            <option value="8">8</option>
            <option value="9">9</option>
            <option value="10">10</option>
            <option value="11">11</option>
            <option value="12">12</option>
            <option value="13">13</option>
            <option value="14">14</option>
            <option value="15">15</option>
            <option value="16">16</option>
            <option value="17">17</option>
            <option value="18">18</option>
            <option value="19">19</option>
            <option value="20">20</option>
            <option value="21">21</option>
            <option value="22">22</option>
            <option value="23">23</option>
            <option value="24">24</option>
            <option value="25">25</option>
            <option value="26">26</option>
            <option value="27">27</option>
            <option value="28">28</option>
            <option value="29">29</option>
            <option value="30">30</option>
            <option value="31">31</option>
          </select>
            <label for="bln"></label><select name="bln" id="bln">
             
      <option value="1" selected="selected">1</option>
            <option value="2">2</option>
            <option value="3">3</option>
            <option value="4">4</option>
            <option value="5">5</option>
            <option value="6">6</option>
            <option value="7">7</option>
            <option value="8">8</option>
            <option value="9">9</option>
            <option value="10">10</option>
            <option value="11">11</option>
            <option value="12">12</option>
            </select>
            <label for="thn"></label>
    <select name="thn" id="thn">
      <option value="2000" selected="selected">2000</option>
              <option value="1999">1999</option>
              <option value="1998">1998</option>
              <option value="1997">1997</option>
              <option value="1996">1996</option>
              <option value="1995">1995</option>
              <option value="1994">1994</option>
              <option value="1993">1993</option>
              <option value="1992">1992</option>
              <option value="1991">1991</option>
              <option value="1990">1990</option>
              <option value="1989">1989</option>
              <option value="1988">1988</option>
              <option value="1987">1987</option>
              <option value="1986">1986</option>
              <option value="1985">1985</option>
              <option value="1984">1984</option>
              <option value="1983">1983</option>
              <option value="1982">1982</option>
              <option value="1981">1981</option>
              <option value="1980">1980</option>
              <option value="1979">1979</option>
              <option value="1978">1978</option>
              <option value="1977">1977</option>
              <option value="1976">1976</option>
              <option value="1975">1975</option>
              <option value="1974">1974</option>
              <option value="1973">1973</option>
              <option value="1972">1972</option>
              <option value="1971">1971</option>
              <option value="1970">1970</option>
              <option value="1969">1969</option>
              <option value="1968">1968</option>
              <option value="1967">1967</option>
              <option value="1966">1966</option>
              <option value="1965">1965</option>
              <option value="1964">1964</option>
              <option value="1963">1963</option>
              <option value="1962">1962</option>
              <option value="1961">1961</option>
              <option value="1960">1960</option>
            </select>
            <div class="spacer"></div>
            <label>Sex
    <span class="small">Jenis kelamin anda</span>
    </label>
            <select name="jekel">
    <option value="Pilih" selected="selected">Choose one... </option>
    <option value="laki-laki" id="jekel">male</option>
    <option value="perempuan" id="jekel">female</option>
    
            </select>
            <div class="spacer"></div>
            <label>Address
            <span class="small">Your address</span>
            </label>
            <input type="text" name="alamat" id="alamat"/>
            <div class="spacer"></div>
            <label>Kota
            <span class="small">Town</span>
            </label>
            <input type="text" name="kota" id="kota"/>
            <div class="spacer"></div>
            <label>Propinsi
            <span class="small">Province</span>
            </label>
            <select name="propinsi">
            <option value="Pilih" selected="selected">Pilih salah satu....</option>
    <option>Nanggroe Aceh Darussalam</option>
    <option>Sumatera Utara</option>
    <option>Sumatera Barat</option>
    <option>Bengkulu</option>
    <option>Riau</option>
    <option>Kepulauan Riau</option>
    <option>Jambi</option>
    <option>Sumatera Selatan</option>
    <option>Lampung</option>
    <option>Kepulauan Bangka Belitung</option>
    <option>DKI Jakarta</option>
    <option>Jawa Barat</option>
    <option>Banten</option>
    <option>Jawa Tengah</option>
    <option>DI Yogyakarta</option>
    <option>Jawa Timur</option>
    <option>Kalimantan Barat</option>
    <option>Kalimantan Tengah</option>
    <option>Kalimantan Selatan</option>
    <option>Kalimantan Timur</option>
    <option>Bali</option>
    <option>Nusa Tenggara Barat</option>
    <option>Nusa Tenggara Timur</option>
    <option>Sulawesi Barat</option>
    <option>Sulawesi Utara</option>
    <option>Sulawesi Tengah</option>
    <option>Sulawesi Selatan</option>
    <option>Sulawesi Tenggara</option>
    <option>Gorontalo</option>
    <option>Maluku</option>
    <option>Maluku Utara</option>
    <option>Papua Barat</option>
    <option>Papua</option>
            </select>
    </fieldset>
        <br>
        <button type="submit">Sign-up</button>
       
      </form>
    </div>
    
    <?php
    };
    ?>
    reg.php
    Code:
    <?php
    $email=$_POST['email'];
    $pwd1=$_POST['pwd1'];
    $pwd2=$_POST['pwd2'];
    $tgl=$_POST['tgl'];
    $bln=$_POST['bln'];
    $thn=$_POST['thn'];
    $tgl_lahir=$tgl.'-'.$bln.'-'.$thn;
    $jekel=$_POST['jekel'];
    $alamat=$_POST['adrress'];
    $kota=$_POST['town'];
    $propinsi=$_POST['province'];
    ?>
    register.php
    Code:
    <?php
    include('output_fns.php');
    do_kepala('Register');
    do_body();
    display_login_form();
    ?>

  2. #2

    RabbieBurns's Avatar
    Join Date
    Apr 2008
    Location
    Sydney
    Posts
    5,532
    Thank Post
    1,341
    Thanked 470 Times in 307 Posts
    Blog Entries
    6
    Rep Power
    200
    Not quite sure what you are asking...

    Are you wanting to verify each field on the register.php page to make sure, for example, they enter a valid email address, or the password is 6-12 characters long?

  3. #3

    Join Date
    Feb 2009
    Location
    Indonesia
    Posts
    18
    Thank Post
    3
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Yes

    Yes,i intending to validate emails,blank text input..How should i do it?Thanks..

  4. #4

    Join Date
    Oct 2008
    Location
    Gosport
    Posts
    64
    Thank Post
    1
    Thanked 18 Times in 13 Posts
    Rep Power
    16
    Hi,

    Firstly could you help us to help you:
    • Be more specific in your question (eg. "I'd like to check the given data for validity and display warning messages next to the specific fields if the data is not valid (eg if it's too long or contains special characters). Any thoughts on how to do this?" )
    • Use [php] tags when posting php code to improve readability.
    • Put a line break before each function to improve readability.
    • Include a brief description of the files (eg "this one does the outputting", "this one grabs the data without any sort of safety checks but I think the checking should probably be done in here?", "this one ties it all together") or at least some comments in the code.

    Grumble done. Moving on to the answer part:

    Now assuming that we've understood you correctly, set register.php to include the reg file:
    PHP Code:
    <?php
    include('output_fns.php');
    do_kepala('Register');
    ...
    ?>
    Get the reg file to do some validation and build a list of error messages when it encounters problems:
    PHP Code:
    <?php
    // only check things if we've got input to check
    $errors = array();
    if( isset(
    $_POST['submit'] ) {
      
    // check email
      
    $email=$_POST['email'];
      
    // email regex courtesy of http://www.regular-expressions.info/email.html
      
    if( !preg_match'/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i'$email )
      {
        
    $email '';
        
    $errors['email'] = 'Email is not valid';
      }
      
      
    // check passwords
      
    $pwd1=$_POST['pwd1'];
      
    $pwd2=$_POST['pwd2'];
      if( 
    $pwd1 == '' ) {
        
    $errors['pwd1l'] = 'First password field not filled in';
      }
      if( 
    $pwd2 == '' ) {
        
    $errors['pwd1l'] = 'Second password field not filled in';
      }
      elseif( 
    $pwd1 != $pwd2 ) {
        
    $pwd1 '';
        
    $pwd2 '';
        
    $errors['pwd2'] = 'Passwords do not match';
      }
      
      
    // and so on and so on checking each field and setting appropriate error messages
    }
    ?>
    Then finally get your login form to output the errors in their right places and with some sort of formatting. In order to avoid massively polluting your output function let's create another function to show each of the errors when called.
    so, add:
    PHP Code:
    /**
     * Displays an error message
     * @param $field string  The field whose error message is to be displayed
     */
    function doError$field )
    {
      if( isset(
    $errors[$field]) ) {
        echo 
    ' <span class="error">'.$errors[$field].'</span>
      }

    (of course you'll need to add a style rule to set the display of class "error". Something like:
    HTML Code:
    <style>
    .error {
      color: red;
      font-weight: bold;
      font-size: 0.9em;
    }
    </style>
    in the <head> of your document or just add the rule to your existing stylesheet if you have one.

    Now we call that function each time we show an input:
    PHP Code:
    <?php
    /**
     * Displays the login form with error messages if any have been generated
     */
    function display_login_form()
    {
    ?>
    <div id="stylized" class="myform">
      <form id="form1" name="form1" method="post" action="reg.php">
        <fieldset>
        <legend >Data keanggotaan</legend>
        <br>
        <label>Email
            <span class="small">Become your id</span>
        </label><?php doError('email'); ?>
        
        <input type="text" name="email" id="email" />
        <label>Password
            <span class="small">6-12 karakter</span>
        </label><?php doError('pwd1'); ?>
        <input type="password" name="pwd1" id="password" />
        <div class="spacer"></div>
        
        <label>Ulangi Password
            <span class="small">6-12 karakter</span>
        </label><?php doError('pwd2'); ?>
        <input type="password" name="pwd2" id="password" />
        <div class="spacer"></div>
        
        // etc, etc, ...
    ?>
    This code has not been tested. The checks you choose to employ to validate your data are your own concern and I do not guarantee that anything here is exactly what you need. Hopefully it'll help you a long way towards where you need to be.

    Hello
    :-Dave

    P.S. You may want to consider putting the values last posted in the fields as default values when the page reloads otherwise the user will have to re-enter their data. For the text fields this is pretty straightforward (add value="<?php echo htmlspecialchars($email); ?>" for example to the input field). For the option lists it's a bit more involved but i'm going to sleep now so I'll let you figure that out for yourself.
    Last edited by lightinthedark; 1st February 2009 at 04:47 AM.

  5. Thanks to lightinthedark from:

    handoyo (1st February 2009)

  6. #5

    RabbieBurns's Avatar
    Join Date
    Apr 2008
    Location
    Sydney
    Posts
    5,532
    Thank Post
    1,341
    Thanked 470 Times in 307 Posts
    Blog Entries
    6
    Rep Power
    200
    beat me to it, but a great answer

    all I was going to say was:

    in the reg.php file for the email verification, change the $email entry to something like
    PHP Code:
    $email $_POST['email'];
    if (!
    strchr($email'@')) {
    echo 
    "Sorry, that isn't a valid email address.";


  7. Thanks to RabbieBurns from:

    handoyo (1st February 2009)

  8. #6

    Join Date
    Feb 2009
    Location
    Indonesia
    Posts
    18
    Thank Post
    3
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Talking Thanks a lot..I'll try it out

    Thanks a lot guys..I'll try to implement it and sorry if my posting is not the way it should be..What i'm trying to do is to validate the email field,etc.For example if the email field is left blank,then it will display errors...

  9. #7

    Join Date
    Feb 2009
    Location
    Indonesia
    Posts
    18
    Thank Post
    3
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    not working

    Hi lightinthedark,i've followed as you says..On the register.php displays

    Code:
    Notice: Undefined index: email in C:\wamp\www\Rekan Doa\reg.php on line 5
    here are the codes that i modified.Did i made mistakes?Should it be display the register.php instead of reg.php when i click submit?By the way i include the files

    //Holds the function to be used for display the pages
    output_fns.php
    PHP Code:
    <?php
    function do_kepala($title){
    ?>

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
    "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
    <title><?php echo $title ?></title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <link rel="stylesheet" href="include/style.css" type="text/css">
    <style>
    .error {
      color: red;
      font-weight: bold;
      font-size: 0.9em;
    }
    </style>
    </head>
    <body>

    <?php
    };
    function 
    do_body()
    {
    ?>
    <br>

    <?php
    };
    function 
    do_footer()
    {
    ?>
        </body>
    </html>

    <?php
    };
    function 
    display_login_form()
    {
    ?>
    <div id="stylized" class="myform">
      <form id="form1" name="form1" method="post" action="reg.php">
        <fieldset>
        <legend >Data keanggotaan</legend>
        <br>
        <label>Email anda
            <span class="small">Jadi login id anda</span>
        </label>
        <input type="text" name="email" id="email" />
        <?php doError('email'); ?>
        <label>Password
            <span class="small">6-12 karakter</span>
        </label>
        <input type="password" name="pwd1" id="password" />
        <div class="spacer"></div>
        <label>Ulangi Password
            <span class="small">6-12 karakter</span>
        </label>
        <input type="password" name="pwd2" id="password" />
        <div class="spacer"></div>
        </fieldset>
        <fieldset>
        <legend>Data pribadi</legend>
        <br>
        <label>Nama 
        <span class="small">Nama lengkap anda</span>
        </label>
        <input type="text" name="nama" id="nama"/>
        <div class="spacer"></div>
        <label for="tgl">Tanggal lahir
        <span class="small">dd/mm/yyyy</span>
        </label>
        <select name="tgl" id="tgl">
            <option value="1" selected="selected">1</option>
            <option value="2">2</option>
            <option value="3">3</option>
            <option value="4">4</option>
            <option value="5">5</option>
            <option value="6">6</option>
            <option value="7">7</option>
            <option value="8">8</option>
            <option value="9">9</option>
            <option value="10">10</option>
            <option value="11">11</option>
            <option value="12">12</option>
            <option value="13">13</option>
            <option value="14">14</option>
            <option value="15">15</option>
            <option value="16">16</option>
            <option value="17">17</option>
            <option value="18">18</option>
            <option value="19">19</option>
            <option value="20">20</option>
            <option value="21">21</option>
            <option value="22">22</option>
            <option value="23">23</option>
            <option value="24">24</option>
            <option value="25">25</option>
            <option value="26">26</option>
            <option value="27">27</option>
            <option value="28">28</option>
            <option value="29">29</option>
            <option value="30">30</option>
            <option value="31">31</option>
          </select>
            <label for="bln"></label><select name="bln" id="bln">
              
          <option value="1" selected="selected">1</option>
            <option value="2">2</option>
            <option value="3">3</option>
            <option value="4">4</option>
            <option value="5">5</option>
            <option value="6">6</option>
            <option value="7">7</option>
            <option value="8">8</option>
            <option value="9">9</option>
            <option value="10">10</option>
            <option value="11">11</option>
            <option value="12">12</option>
            </select>
            <label for="thn"></label>
        <select name="thn" id="thn">
          <option value="2000" selected="selected">2000</option>
              <option value="1999">1999</option>
              <option value="1998">1998</option>
              <option value="1997">1997</option>
              <option value="1996">1996</option>
              <option value="1995">1995</option>
              <option value="1994">1994</option>
              <option value="1993">1993</option>
              <option value="1992">1992</option>
              <option value="1991">1991</option>
              <option value="1990">1990</option>
              <option value="1989">1989</option>
              <option value="1988">1988</option>
              <option value="1987">1987</option>
              <option value="1986">1986</option>
              <option value="1985">1985</option>
              <option value="1984">1984</option>
              <option value="1983">1983</option>
              <option value="1982">1982</option>
              <option value="1981">1981</option>
              <option value="1980">1980</option>
              <option value="1979">1979</option>
              <option value="1978">1978</option>
              <option value="1977">1977</option>
              <option value="1976">1976</option>
              <option value="1975">1975</option>
              <option value="1974">1974</option>
              <option value="1973">1973</option>
              <option value="1972">1972</option>
              <option value="1971">1971</option>
              <option value="1970">1970</option>
              <option value="1969">1969</option>
              <option value="1968">1968</option>
              <option value="1967">1967</option>
              <option value="1966">1966</option>
              <option value="1965">1965</option>
              <option value="1964">1964</option>
              <option value="1963">1963</option>
              <option value="1962">1962</option>
              <option value="1961">1961</option>
              <option value="1960">1960</option>
            </select>
            <div class="spacer"></div>
            <label>Jenis Kelamin
        <span class="small">Jenis kelamin anda</span>
        </label>
            <select name="jekel">
         <option value="Pilih" selected="selected">Pilih salah satu... </option>
         <option value="laki-laki" id="jekel">Laki-laki</option>
         <option value="perempuan" id="jekel">Perempuan</option>
         
            </select>
            <div class="spacer"></div>
            <label>Alamat 
            <span class="small">Alamat lengkap anda</span>
            </label>
            <input type="text" name="alamat" id="alamat"/>
            <div class="spacer"></div>
            <label>Kota 
            <span class="small">Kota anda</span>
            </label>
            <input type="text" name="kota" id="kota"/>
            <div class="spacer"></div>
            <label>Propinsi 
            <span class="small">Propinsi anda</span>
            </label>
            <select name="propinsi">
            <option value="Pilih" selected="selected">Pilih salah satu....</option>
         <option>Nanggroe Aceh Darussalam</option>
        <option>Sumatera Utara</option>
        <option>Sumatera Barat</option>
        <option>Bengkulu</option>
        <option>Riau</option>
        <option>Kepulauan Riau</option>
        <option>Jambi</option>
        <option>Sumatera Selatan</option>
        <option>Lampung</option>
        <option>Kepulauan Bangka Belitung</option>
        <option>DKI Jakarta</option>
        <option>Jawa Barat</option>
        <option>Banten</option>
        <option>Jawa Tengah</option>
        <option>DI Yogyakarta</option>
        <option>Jawa Timur</option>
        <option>Kalimantan Barat</option>
        <option>Kalimantan Tengah</option>
        <option>Kalimantan Selatan</option>
        <option>Kalimantan Timur</option>
        <option>Bali</option>
        <option>Nusa Tenggara Barat</option>
        <option>Nusa Tenggara Timur</option>
        <option>Sulawesi Barat</option>
        <option>Sulawesi Utara</option>
        <option>Sulawesi Tengah</option>
        <option>Sulawesi Selatan</option>
        <option>Sulawesi Tenggara</option>
        <option>Gorontalo</option>
        <option>Maluku</option>
        <option>Maluku Utara</option>
        <option>Papua Barat</option>
        <option>Papua</option>
            </select>
        
            </fieldset>
        <br>
        
        <button type="submit">Sign-up</button>
         </form>
    </div>
    <?php
    };
    //the code that you gave me
    function doError$field )
    {
      if( isset(
    $errors[$field]) ) {
        echo 
    '<span class="error">'.$errors[$field].'</span>';
      }
    };
    ?>
    //Used to validate values and save to database
    reg.php

    PHP Code:
    <?php 

    include("db.inc.php");

    $email=$_POST['email'];
    $pwd1=$_POST['pwd1'];
    $pwd2=$_POST['pwd2'];
    $tgl=$_POST['tgl'];
    $bln=$_POST['bln'];
    $thn=$_POST['thn'];
    $tgl_lahir=$tgl.'-'.$bln.'-'.$thn;
    $jekel=$_POST['jekel'];
    $alamat=$_POST['alamat'];
    $kota=$_POST['kota'];
    $propinsi=$_POST['propinsi'];

    //this one is from RabbieBurns
    $errors = array();
    if( isset(
    $_POST['submit'] )) {
      
    // check email
      
    $email $_POST['email'];
    if (!
    strchr($email'@')) {
    echo 
    "Sorry, that isn't a valid email address.";
    }  
      
      
    // check passwords
      
    $pwd1=$_POST['pwd1'];
      
    $pwd2=$_POST['pwd2'];
      if( 
    $pwd1 == '' ) {
        
    $errors['pwd1l'] = 'First password field not filled in';
      }
      if( 
    $pwd2 == '' ) {
        
    $errors['pwd1l'] = 'Second password field not filled in';
      }
      elseif( 
    $pwd1 != $pwd2 ) {
        
    $pwd1 '';
        
    $pwd2 '';
        
    $errors['pwd2'] = 'Passwords do not match';
      }
      
      
    // and so on and so on checking each field and setting appropriate error messages
    }

    ?>
    //display the registration form
    register.php
    PHP Code:
    <?php
    include('output_fns.php');
    include(
    'reg.php');
    do_kepala('Register');
    do_body();
    display_login_form();
    ?>
    Attached Files Attached Files

  10. #8

    Join Date
    Oct 2008
    Location
    Gosport
    Posts
    64
    Thank Post
    1
    Thanked 18 Times in 13 Posts
    Rep Power
    16
    The output there is only a notice, so it looks like you've got php set to be very strict. That's no problem, but be prepared for more, similar things as you go on.
    The warning says that the index 'email' isn't defined on line 5 of reg.php . Looking at that line I see it's where you assign the value of $_POST['email'] to your variable. I also notice that in the code given you're assigning to that variable twice (once in your original block, once in the block from my suggestion) which is un-necessary. To solve problem 1 (invalid index) i suggest using a ternary if (see "ternary operator" on this page ). For problem 2 (assigning twice), i suggest removing the block before the stuff I gave you. That ends up with:

    PHP Code:
    <?php 
    include("db.inc.php");

    $errors = array();
    if( isset(
    $_POST['submit'] )) {
      
    // check email
      // (this one is from RabbieBurns)
      
    $email = ( isset($_POST['email']) ? $_POST['email'] : '' );
      if (!
    strchr($email'@')) {
        echo 
    "Sorry, that isn't a valid email address.";
      }  
      
      
    // check passwords
      
    $pwd1=( isset($_POST['pwd1']) ? $_POST['pwd1'] : '' );
      
    $pwd2=( isset($_POST['pwd2']) ? $_POST['pwd2'] : '' );
      if( 
    $pwd1 == '' ) {
        
    $errors['pwd1l'] = 'First password field not filled in';
      }
      if( 
    $pwd2 == '' ) {
        
    $errors['pwd1l'] = 'Second password field not filled in';
      }
      elseif( 
    $pwd1 != $pwd2 ) {
        
    $pwd1 '';
        
    $pwd2 '';
        
    $errors['pwd2'] = 'Passwords do not match';
      }
      
      
    // and so on and so on checking each field and setting appropriate error messages
    }

    ?>
    As for
    Should it be display the register.php instead of reg.php when i click submit?
    Yes. kinda. I had assumed that that's what it was doing (didn't read your code as thoroughly as I might have done). If you want to go to reg instead of register then reg is going to have to call the same page-displaying stuff that register does in order to get the form to re-display with error messages. I had thought reg.php was going to be just a "process the data" file rather than doing any display or other stuff. It's up to you how you put the pieces together really, but everything you need (i think) is there (subject to debugging and moulding to your specific plans and needs).

    As I said before, the code isn't tested and will probably need a bit of adjustment to be exactly what you need. I'm just trying to point you in what seems like a good direction.

    BTW, sorry if I was a bit grumpy on my first reply where I criticised your original request style. It was very late at night and my diplomacy/tact circuits weren't running at full power. :-)

    Hello
    :-Dave
    Last edited by lightinthedark; 1st February 2009 at 07:40 PM.

  11. Thanks to lightinthedark from:

    handoyo (2nd February 2009)

  12. #9

    Join Date
    Feb 2009
    Location
    Indonesia
    Posts
    18
    Thank Post
    3
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Thats ok

    Thanks Dave,i got more knowledge here..Btw,that's ok Dave about your criticism..I learn how to post the way it should be so other people can understand what kind of help that i ask for.



SHARE:
+ Post New Thread

Similar Threads

  1. Using forms in excel
    By bobharding in forum How do you do....it?
    Replies: 3
    Last Post: 25th January 2009, 07:33 AM
  2. Outlook 2003 Forms help
    By roo20487 in forum Web Development
    Replies: 1
    Last Post: 6th March 2008, 09:38 AM
  3. Validating Windows with different Serial
    By johnkay21 in forum Windows
    Replies: 4
    Last Post: 14th June 2007, 12:00 PM
  4. forms
    By beeswax in forum Web Development
    Replies: 5
    Last Post: 28th February 2007, 11:14 AM
  5. Forms not working in IE 6x
    By mark in forum Windows
    Replies: 1
    Last Post: 11th October 2006, 09:53 AM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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