Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

Help with Passing Variables to Relational Web Pages

New Here ,
Mar 13, 2007 Mar 13, 2007

Copy link to clipboard

Copied

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.
TOPICS
Server side applications

Views

284
Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 13, 2007 Mar 13, 2007

Copy link to clipboard

Copied

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

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 14, 2007 Mar 14, 2007

Copy link to clipboard

Copied

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.


Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 16, 2007 Mar 16, 2007

Copy link to clipboard

Copied

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

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 17, 2007 Mar 17, 2007

Copy link to clipboard

Copied

LATEST
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/

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines