Jump to content

Collect data and use in another


Go to solution Solved by Barand,

Recommended Posts

Hi,

 

I am doing a survey and need a little guidance.   I have data being selected from one table and I am trying to store it in another.     I have no problem selecting the data and displaying it, I just can't get it to continue on with the new survey.    Here is the file showing the data collected:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Question 1</title>
</head>
<body>
<?php
session_start();
$_SESSION['name'] = $_POST['name'];
$_SESSION['cslogin'] = $_POST['cslogin'];
$_SESSION['domain'] = $_POST['domain'];
$_SESSION['project'] = $_POST['project'];
$_SESSION['ODM'] = $_POST['ODM'];
$_SESSION['hwphase'] = $_POST['hwphase'];
$_SESSION['ppmid'] = $_POST['ppmid'];
$_SESSION['survey'] = $_POST['survey'];
$_SESSION['month'] = $_POST['month'];
?>
Name: <?php echo $_POST['name'];?><br>
CS Login: <?php echo $_POST['cslogin'];?><br>
Domain:  <?php echo $_POST['domain'];?><br>
Project:  <?php echo $_POST['project'];?><br>
ODM:  <?php echo $_POST['ODM'];?><br>
HW Phase:  <?php echo $_POST['hwphase'];?><br>
PPM ID:  <?php echo $_POST['ppmid'];?><br>
Survey:  <?php echo $_POST['survey'];?><br>
Month: <?php echo $_POST['month'];?><br>

Everything from table 1 is displayed above.   No problem.

 

Here is the next page after this.  Question #1 has already been answered:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Question 2</title>
</head>
<body>
<?php
session_start();
$name = $_SESSION['name'];
$cslogin = $_SESSION['cslogin'];
$domain = $_SESSION['domain'];
$project = $_SESSION['project'];
$ODM = $_SESSION['ODM'];
$hwphase = $_SESSION['hwphase'];
$ppmid = $_SESSION['ppmid'];
$survey = $_SESSION['survey'];
$month = $_SESSION['month'];
$Q1 = $_SESSION['Q1'];
$comment1 = $_SESSION['comment1'];
?>
Name:  <?php echo $_SESSION['name'];?><br>
Q1: <?php echo $_SESSION['Q1'];?><br>
Comments: <?php echo $_SESSION['comment1'];?><br>

It displays question 1 and comments with no problem.    This is where the "name - month" is lost.   

 

How would I have name - month continue on to be store in a new table?

 

I greatly appreciate your help.

 

Thanks!!

 

Note:  based on the question for #1, the user is redirected to question 2 or question 3.   Here is the file that is between Q1 and Q2

<?php
session_start(); 
$_SESSION['name'] = $_POST['name'];
$_SESSION['cslogin'] = $_POST['cslogin'];
$_SESSION['domain'] = $_POST['domain'];
$_SESSION['project'] = $_POST['project'];
$_SESSION['ODM'] = $_POST['ODM'];
$_SESSION['hwphase'] = $_POST['hwphase'];
$_SESSION['ppmid'] = $_POST['ppmid'];
$_SESSION['survey'] = $_POST['survey'];
$_SESSION['month'] = $_POST['month'];
$_SESSION['Q1'] = $_POST['Q1'];
$_SESSION['comment1'] = $_POST['comment1'];
switch ($_POST['Q1']) {
case "No":
   $url = "filename";
break;
case "Yes":
   $url = "http://odmQ3_a.php";
break;
case "Supplier Assessment is ongoing and issues still being worked":
  $url = "odmQ3_a.php";
}
header("Location: $url");
?>
Edited by Ch0cu3r
Added code tags
Link to comment
https://forums.phpfreaks.com/topic/294063-collect-data-and-use-in-another/
Share on other sites

I have no idea what you are asking.

 

But I can tell you are using session_start() incorrectly. It should only used before any output, this includes code that is outside of the php tags too. 

 

NOTE: When posting code please wrap it within


tags or click the <> button in the editor. I have edited your post for you.

The next page after the POST data page is this:

 

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Question 2</title>
</head>
<body>
<?php
session_start
();
$name = $_SESSION['name'];
$cslogin = $_SESSION['cslogin'];
$domain = $_SESSION['domain'];
$project = $_SESSION['project'];
$ODM = $_SESSION['ODM'];
$hwphase = $_SESSION['hwphase'];
$ppmid = $_SESSION['ppmid'];
$survey = $_SESSION['survey'];
$month = $_SESSION['month'];
$Q1 = $_SESSION['Q1'];
$comment1 = $_SESSION['comment1'];
?>
Name:  <?php echo $_SESSION['name'];?><br>
Q1: <?php echo $_SESSION['Q1'];?><br>
Comments: <?php echo $_SESSION['comment1'];?><br>

 

Is this where I am loosing the data?   How would I re-send the POST data?   I greatly appreciate it.

 

Thanks

Let me get it straight.

 

You have a page that does this

$_SESSION['name'] = $_POST['name'];
$_SESSION['cslogin'] = $_POST['cslogin'];
$_SESSION['domain'] = $_POST['domain'];
$_SESSION['project'] = $_POST['project'];
$_SESSION['ODM'] = $_POST['ODM'];
$_SESSION['hwphase'] = $_POST['hwphase'];
$_SESSION['ppmid'] = $_POST['ppmid'];
$_SESSION['survey'] = $_POST['survey'];
$_SESSION['month'] = $_POST['month'];

Then a page that decides whether to go to Q2 or Q3 that does this (even though there is no mention of Q2)

$_SESSION['name'] = $_POST['name'];
$_SESSION['cslogin'] = $_POST['cslogin'];
$_SESSION['domain'] = $_POST['domain'];
$_SESSION['project'] = $_POST['project'];
$_SESSION['ODM'] = $_POST['ODM'];
$_SESSION['hwphase'] = $_POST['hwphase'];
$_SESSION['ppmid'] = $_POST['ppmid'];
$_SESSION['survey'] = $_POST['survey'];
$_SESSION['month'] = $_POST['month'];
$_SESSION['Q1'] = $_POST['Q1'];
$_SESSION['comment1'] = $_POST['comment1'];

then the Q2 page

<title>Question 2</title>
</head>
<body>
<?php
session_start();
$name = $_SESSION['name'];
$cslogin = $_SESSION['cslogin'];
$domain = $_SESSION['domain'];
$project = $_SESSION['project'];
$ODM = $_SESSION['ODM'];
$hwphase = $_SESSION['hwphase'];
$ppmid = $_SESSION['ppmid'];
$survey = $_SESSION['survey'];
$month = $_SESSION['month'];

So my question was "When going to the second above, how are the POST vars re-sent?"

 

You wouldn't need to - just re-use the session vars. Don't reset them to the (empty) post vars.

Yes, I have this first:

 

session_start();

$_SESSION['name'] = $_POST['name'];
$_SESSION['cslogin'] = $_POST['cslogin'];
$_SESSION['domain'] = $_POST['domain'];
$_SESSION['project'] = $_POST['project'];
$_SESSION['ODM'] = $_POST['ODM'];
$_SESSION['hwphase'] = $_POST['hwphase'];
$_SESSION['ppmid'] = $_POST['ppmid'];
$_SESSION['survey'] = $_POST['survey'];
$_SESSION['month'] = $_POST['month'];

 

Then it is directed to this:

 

session_start(); 

$_SESSION['name'] = $_POST['name'];
$_SESSION['cslogin'] = $_POST['cslogin'];
$_SESSION['domain'] = $_POST['domain'];
$_SESSION['project'] = $_POST['project'];
$_SESSION['ODM'] = $_POST['ODM'];
$_SESSION['hwphase'] = $_POST['hwphase'];
$_SESSION['ppmid'] = $_POST['ppmid'];
$_SESSION['survey'] = $_POST['survey'];
$_SESSION['month'] = $_POST['month'];
$_SESSION['Q1'] = $_POST['Q1'];
$_SESSION['comment1'] = $_POST['comment1'];

 

 

The for the question 2 start I have this:

 

session_start();

$name = $_SESSION['name'];
$cslogin = $_SESSION['cslogin'];
$domain = $_SESSION['domain'];
$project = $_SESSION['project'];
$ODM = $_SESSION['ODM'];
$hwphase = $_SESSION['hwphase'];
$ppmid = $_SESSION['ppmid'];
$survey = $_SESSION['survey'];
$month = $_SESSION['month'];
$Q1 = $_SESSION['Q1'];
$comment1 = $_SESSION['comment1'];

 

So I should eliminate question 2 start and leave it as is?

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.