Skip to main content
Participant
March 13, 2007
Question

Help with Passing Variables to Relational Web Pages

  • March 13, 2007
  • 4 replies
  • 306 views
I am trying to create several webpages that require ID's from the previous page to populate the database tables attached to them. Please help. What I am trying to do:

Page 1: Student Information (Create a New Record)
After creating new record, have server post the unique record ID (StudentID-Primary Key, auto-generated) that was created with the new record and pass it to the next page

Page 2: Family Information (Create New Record) Pages (Connected to page 1 via studentID.)
Have web page get the unique StudentID record created on page 1 and use this to fill in the form on this page. So basically connect the family info back to the student info.

The relationships are set up in MYSQL, but how can you pass variables so it can populate the tables properly? Detailed information would be great as I am a beginner and have read every book, but still can't find a good answer. Please help.

Thanks.

Testing Website found at http://www.mesa.pdx.edu/conference/registration/test1.php
http://www.mesa.pdx.edu/conference/registration/test2.php

Attached is code for page one.
This topic has been closed for replies.

4 replies

Inspiring
March 17, 2007
sock_s wrote:
> Thanks for the input. I was finally able to link my relational pages. One new
> error I encountered is the variables are not passed consistently to the pages.

With the small snippet of code that you have shown, it's a wonder that
any information is being passed.

> <?php session_start();
> $_REQUEST['user']; <--------- This does nothing
> $StudentID = $_SESSION['user'];
> $_REQUEST['FamilyID1']; <----------- This does nothing
> $FamilyID1 = $_SESSION['FamilyID1']; ?>
> <?php require_once('../../Connections/MySQL.php'); ?>

What are you trying to do here? The two $_REQUEST variables do nothing.
You're also assigning the value of $_SESSION variables to ordinary
variables. Is that what you want to do? If so, is it really necessary?
The value is already held in the $_SESSION variable, so you would
normally use just that.

If you're trying to store a value passed through a form, you should
normally do it like this:

<?php
session_start();
if (isset($_POST['user'])) {
$_SESSION['user'] = $_POST['user'];
}
?>

$_SESSION['user'] is then available on all pages that begin with
session_start().

--
David Powers, Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
Author, "PHP Solutions" (friends of ED)
http://foundationphp.com/
sock_sAuthor
Participant
March 17, 2007
Thanks for the input. I was finally able to link my relational pages. One new error I encountered is the variables are not passed consistently to the pages. Sometimes my tables are populated with sporatic Null values for some of the session variables. Other times I run the application and things work great any ideas.
Code is from session page on line 1

<?php session_start();
$_REQUEST['user'];
$StudentID = $_SESSION['user'];
$_REQUEST['FamilyID1'];
$FamilyID1 = $_SESSION['FamilyID1']; ?>
<?php require_once('../../Connections/MySQL.php'); ?>

Inspiring
March 14, 2007
Put the data in session variables.

On each page add the line below to the top of the page (line 1):

<?php session_start(); ?>

On the first page, put the id in the session variable:

<?php $_SESSION['user'] = $rs_recordset['id_field']; ?>

or similar, according to where your getting the id from.

On the session page, use $_SESSION['user'] to filter the database table to
pull up the record linked to the id held in session "user"

--
Gareth
http://www.phploginsuite.co.uk/
PHP Login Suite V2 - 34 Server Behaviors to build a complete Login system.


Inspiring
March 13, 2007
>
> The relationships are set up in MYSQL, but how can you pass
> variables so it can populate the tables properly?

I use passing by url a lot but if the data is more sensitve I would say
passing as a session variable.