LT   EN   RU  
Wednesday 8 December 2021 Straipsniai.lt - Independent and informative portal
Home
Phorum
Contacts
Login
Register   Login
News subscribe
Subscribe   Unsubscribe
Partners
www.slaptai.lt www.gamezone.lt
www.penki.lt www.hakeriai.lt
   
   
Advertising
Statistic
Visits since 2002 09 12 - 68348466
Pages in Straipsniai.lt: 40735
  
  Computers > Computer technologies > Programing > PHP
Lankomumo reitingas Print version Print version
Multiple Page Forms

So you have this long, involved form. Rather than present the user with a myriad of inputs on a single page, you want to break this up into separate form pages. So now you're asking, "How do you make multiple page forms?" I'm glad you asked. It's easy!

Here's one easy way. Consider the following small bit of code, which assumes that your form is submitted via the POST method:

<?php
  foreach($_POST as $key=>$value){
    if ($key!="submit"){
      $value=htmlentities(stripslashes(strip_tags($value)));
      echo "\t<input type=\"hidden\" name=\"$key\" value=\"$value\">
";
    }
  }
?>

What's that bit of code do? If you were to place the above code between your opening <form> tag and the closing </form> tag, it will look at all values received from the prior page, strips out any HTML tags, replaces any character entities with their appropriate code and writes them to hidden inputs in the current form. It will skip a value of "submit" so it won't duplicate your submit button. If you name your submit button something other than "submit", you should change that bit in the code.

Here is a simple form that you can try out. First, look at the source code of this page. In particular, look at the <form> and confirm that there are no hidden inputs. The form simply submits back to this page. Type something in the box and click the submit button. It doesn't matter what you type, the value will simply be plugged into the resultant page as a hidden input in the form.

Name:

Now, after submitting the form, look at the source code again. Now you will notice that the value you typed in the input box is included as a hidden field in the form. Okay, let me insert a small disclaimer here. This is only an example to demonstrate a technique. If you look at the source code after submitting the form, you will notice that you have two inputs with the same name, one hidden and one visible. If you had submitted the form to a different page, with different inputs, that would not happen.

            
Lankomumo reitingas

Diskusijos - Discusions

Versija spausdinimui - Print version

Atgal
Random tags:    People (56)    Mysticism 2 (3)    Dogs (17)    Telecomunication (40)    Health (20)    Narcotics no (13)    Aviculture (2)    Programing (13)    Security (22)    Pedagogics (10)    Medicine (5)    Heathendom (3)    Suckling (10)    Dragons (13)    Chess (10)    Eurointegration (4)    Kisses (13)    Business (25)    Linux/Unix (2)    Prose (11)    UFO (39)    Hunting (3)    Guns (11)    Biology (66)    Show-business (11)    Philosophy (2)    Architecture (2)    Cats (14)    Cryptography (10)    Modems (2)    SSL certificates (10)    Egypt (43)    Astrology (10)    Viruses (10)    Vampire (6)    Agrobusiness (2)    Culture (57)    Law (11)    Photography (3)    Martial arts (7)    Open source (9)    Yoga (4)    Automobiles (10)    Mother and child (17)    Aviation (10)    Soldiership (12)    Operating systems (19)    Intercourse (265)    Economics2 (2)    Geography (10)
1. Simple PHP mail script
2. PHP Include File
1. PHP Include File
2. Simple PHP mail script
Map