shinjuo
shinjuo

Reputation: 21042

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

Upvotes: 1

Views: 745

Answers (3)

kushalbhaktajoshi
kushalbhaktajoshi

Reputation: 4688

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()`.

Upvotes: 2

Christian
Christian

Reputation: 19750

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'];
?>

Upvotes: 3

bensiu
bensiu

Reputation: 25604

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

Upvotes: 1

Related Questions