Results 1 to 5 of 5

Thread: How to reload form

  1. #1
    Join Date
    May 2008
    Posts
    27

    How to reload form

    Hi All
    I am creating a simple web site which will display user ads, so I have some forms they submit, here is a snippet of the code:
    Code:
    <div class="createlisting">
    
    <div class="clinput">
    Ad Title... (up to 100 characters)<br>
    <?php
    print '<input type="text" name="item_title"';
    print s_att("item_title","value",100);
    if (isset($err["item_title_err"]))
    {print ' class="err"> '.$err["item_title_err"];}
    else
    {print '>';}
    ?>
    <br>
    </div>
    I need to get users to agree to my terms and conditions, so something like:

    if //checkbox they can click to agree else // if unchecked, reload the same form...
    Not sure how to do this, can anyome help?

  2. #2
    Join Date
    Oct 2005
    Posts
    2,393
    That is why people use form classes / functions/ whatever

    Then you can do stuff like
    Code:
    $form->set('checkbox','mycheckbox','myvalue',ISSET);
    
    if($form->validate()){
    
    // form validates
    
    } else {
    
    $form->show();
    
    }
    Otherwise you have to cede like
    Code:
    if(!empty($_POST['myform'])){
    
    array_push($aErrors,'mycheckbox');
    
    }
    
    // etc
    
    
    if(sizeof($aErors)){
    
    inlcude('form.php');
    
    } else {
    
    // form validates
    
    }
    
    
    form.php
    
    <input type="checkbox" name="mycheckbox">
    <?php if(isset($aErrors['mycheckbox'])){
    
    echo 'Whoops';
    
    }?>
    etc

  3. #3
    Join Date
    Feb 2008
    Posts
    1,852
    Quote Originally Posted by Reegan View Post
    That is why people use form classes / functions/ whatever

    Then you can do stuff like
    [CODE]$form->set('checkbox','mycheckbox','myvalue',ISSET);
    So what's your favorite form class?

  4. #4
    Join Date
    Oct 2005
    Posts
    2,393
    Classes are irrelevant to this situation. In fact classes should never be used with PHP. They offer very few advantages and make code totally obscure. That is not welcome and should be avoided at all costs in any validation action.

    If you need to use classes you should not be using a script language anyway.

  5. #5
    Join Date
    Feb 2008
    Posts
    1,852
    Quote Originally Posted by Reegan View Post
    Classes are irrelevant to this situation. In fact classes should never be used with PHP. They offer very few advantages and make code totally obscure. That is not welcome and should be avoided at all costs in any validation action.

    If you need to use classes you should not be using a script language anyway.
    I dont agree. Classes are actually great. They make code much more reliable and maintainable.

Similar Threads

  1. Replies: 5
    Last Post: 25-05-2011, 10:21 PM
  2. Replies: 2
    Last Post: 02-05-2011, 07:06 AM
  3. How to Auto Populate fields from sub form to form?
    By mich43 in forum Windows Software
    Replies: 6
    Last Post: 09-11-2010, 11:29 PM
  4. Procedure in VB to create form inside another form
    By Jalabala in forum Software Development
    Replies: 3
    Last Post: 16-11-2009, 02:14 PM
  5. Problem reloading MDI child form in main form.
    By AFFAN in forum Software Development
    Replies: 3
    Last Post: 30-01-2009, 09:05 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,315,846.12887 seconds with 17 queries