Jump to content

[SOLVED] Passing POST variables through SESSIONS


kizofilax

Recommended Posts

Hello, i have been having problems in getting my POST variables through multiple pages using sessions

 

Here is the first part of my code for the first page called "statePage1.php"

 

<?php

 

 

session_start();

 

$SESSION["p1_q1"]=$_POST["p1_q1"];

 

?>

 

<html>

 

<body>

 

<h1>This is the first page</h1>

 

<form id="page1" name="page1" method="post" action="statePage2.php">

 

<table>

 

<tr>

 

<td>Q1: </td>

 

<td><input type="text" id="p1_q1" name="p1_q1" /></td>

 

 

This is part of the second page "statePage2.php"

 

<?php

 

session_start();

 

 

Print_r ($_SESSION);

 

 

?>

 

<html>

 

<body>

 

<h1>This is the second page</h1>

 

The print function doesnt print anything so i dont know why the variables are not getting assigned to the SESSION var.

 

When i do on the first page

 

$SESSION["p1_q1"]="TEST"; it prints it on the second page but when I use the variables from the POST and the form i cant get it to work

 

 

Any ideas?

 

 

Thanks

The form in the first page sends the data to the second page, so setting $_SESSION['p1_q1'] to $_POST['p1_q1'] on page one is useless because $_POST['p1_q1'] is empty at that time. You should have placed that in page 2 instead.

 

OK its working now!! Thanks =D

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.