LT   EN   RU  
2021 г. апрель 14 д., среда Straipsniai.lt - Информационный портал
  
  Компьютеры > Компьютерные технологии > Программирование > 
Lankomumo reitingas Версия для печати Версия для печати
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

Oбсудить на форуме - Oбсудить на форуме

Версия для печати - Версия для печати

Назад
Случайные теги:    Фэншуй (4)    Архитектура (3)    Гостья из будущего (35)    Фехтирования (6)    Кошки (11)    Археология (3)    Лов рыбы (11)    Психология (27)    Хоби (27)    Педагогика (10)    Скейборды (2)    Боевые искусства (10)    Латинский язык (7)    Звуковые системы (8)    Генетика (10)    Фильмы (10)    Цветоводство (6)    Сертификаты SSL (10)    Наука (90)    НЛО (24)    Кино (45)    Настольные игры (17)    Туризм (25)    Шахматы (2)    Мистика (83)    Пиво (29)    Кормление (4)    Технологий (4)    Астрономия (10)    Операционные системы (8)    География (4)    Страны (22)    Политика (3)    Компьютеры (290)    Здаровья ребёнка (2)    Йога (9)    Право человека (8)    Психиатрия (13)    Спортивная гимнастика (4)    Общение (322)    Linux/Unix (5)    Мама и ребенок (19)    Бизнес и финансы (20)    Анна Ахматова (3)    Накопители (2)    Наркопсихотерапия (2)    Экология (18)    Казино (9)    Английский язык (2)    Помощ и превенция (2)
Map