SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Thread: form procession

  1. #1
    SitePoint Addict itsource's Avatar
    Join Date
    Jun 2001
    Location
    Thailand
    Posts
    369
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    form procession

    1. when user type input in the form and click submit button, when input is error the form was show again and retain the data that the user submitted when the error was displayed

    please Look at this two code.

    PHP Code:
    <INPUT TYPE="text" NAME="first" VALUE="<?php echo $HTTP_POST_VARS['first']; ?>">
    and compare with this

    PHP Code:
    <INPUT TYPE="text" NAME="first" VALUE="<?php echo $first ?>">
    two method give same result that display data in the textbox that user type in it.
    Is different between

    $HTTP_POST_VARS['first']
    and
    $first
    ----------------------------------------------------

    2. I see many code like this
    PHP Code:
    <?php if($action == "display") { 
                include(
    "form.ihtml"); 
             } elseif (
    $action == "process") { 
                 include(
    "success.ihtml"); 
           } else { 
                   include(
    "error.ihtml"); 
           } 
     
    ?>
    this code include form html. Why they use *.ihtml instead *.html ? What different?
    ---------------------------------------------------

    3. continue from question 1 this code below
    PHP Code:
    foreach($HTTP_POST_VARS as $key => $val) { 
    $funcname "validate_$key"

       if(
    function_exists($funcname)) { 



                if(!
    $funcname($val)) { 

                   
    $errors[] = "Field $key was invalid"

                } 
             } 

          } 
    Can you explain me what does it mean?
    foreach($HTTP_POST_VARS as $key => $val)

    ------------------------------------------
    Thank You.


  2. #2
    SitePoint Addict itsource's Avatar
    Join Date
    Jun 2001
    Location
    Thailand
    Posts
    369
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorry! The topic is form processing not form procession

  3. #3
    SitePoint Evangelist
    Join Date
    Feb 2000
    Location
    England
    Posts
    568
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    1. no difference as far as i know, two different ways at getting same data.
    2. the use ihtml basically because it is a different name for a template file. It is just what that author has wanted to call their template files as opposed to normal html files. If you renamed them to .html or .txt or .anything it would still work.
    3. that just runs through all the data that was sent by the browser (i think only the user input) 1 by 1 so you can validate the input, ie just looping through the $HTTP_POST_VARS array.

  4. #4
    Node mutilating coot timnz's Avatar
    Join Date
    Feb 2001
    Location
    New Zealand
    Posts
    516
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Also in some situations it is better to use $HTTP_POST_VARS array because if someone taps onto the URL like
    something.php?first=somethingpeculiar
    then in some situations that can corrupt your processing and things if say $first is only meant to be a number, so you would use $HTTP_POST_VARS to only get the data that was POSTED in the form, rather than using data that was sent using the GET method. So what you would do would be to extract $HTTP_POST_VARS and thus it will overwrite anything a user has tried to tap onto the URL. Of course you should always be checking for the right sort of data when you process the form anyway.

    That was kinda long winded I'm sorry, but I hope it explains it


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
  •