开发者

Passing form data

I have a form and I want to pass the form data across 2 pages. The user clicks submit it passes to the next page and is checked开发者_运维问答 then it is passed to the last page. I am having trying to find out how to do this. I am currently using php, html, and javascript


First page would have the form and inputs on it.

Second page (which I'm assuming it just a php script):

<?php
$name = $_POST['name'];

if ($name != '') {
  session_start();
  $_SESSION['name'] = $name;
  // redirect to third page
}
else {
  // whatever you need to do
}
?>

Third page:

<?php
  echo $_SESSION['name'];
?>


You have to use session to pass the values in multiple pages. Suppose you have the data like

`$_POST['field1']`, `$_POST['field2']`

Now you have to use session variable in the page

<?php
session_start()
$_SESSION['field1'] = $_POST['field1']
$_SESSION['field2'] = $_POST['field2']

Now you can use the session variables in other pages initiating `session_start()`.


place all inputs from first page on second page as hidden elements

or

place from first page input's values in session / database / or somewhere else and have them handy durring processing second page

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜