Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
$FAIL = " ";
$TRY = " ";

$id = $_POST['id'];
$class = $_POST['course'];

$sql = "SELECT * FROM $db_table10 WHERE id = '$id'";
$result = mysql_query ($sql, $connect) or die('Query 4 failed: ' .
$num = mysql_num_rows($result);

if ($num == 0)
echo "$id <BR>";
echo "$class<BR>";
echo "$num<BR>";
echo "$result <BR>";
echo "<meta http-equiv='Refresh' content='1;url=$FAIL'>";
$passid = $id;
$passcid = $class;
echo "<meta http-equiv='Refresh' content='3;url=$TRY'>";

<FORM ACTION="survey.php" METHOD="post" NAME="survey" ID="survey">
<TD>Enter ID Code</TD>
<TD><INPUT TYPE="text" NAME="id" SIZE="15" MAXLENGTH="13"></TD>
<TD VALIGN="top">Select A Course:</TD>
<INPUT TYPE="radio" NAME="course" VALUE="cita110">Introduction To
Software Applications<BR>
<INPUT TYPE="radio" NAME="course" VALUE="cita210">Visual Programming
&amp; Development Tools<BR>
<INPUT TYPE="radio" NAME="course" VALUE="cita330">Web Publishing<BR>
<INPUT TYPE="radio" NAME="course" VALUE="cita405">Project
<INPUT TYPE="radio" NAME="course" VALUE="cita420">Programming For The
<TD><INPUT TYPE="submit" NAME="entersurvey" VALUE="Submit"></TD>
<DIV ID="footer">
<STRONG><?PHP INCLUDE("../includes/countdown.txt");?></STRONG>
I have it working to the point that it verifies unique id code is in
the db.  Then it takes me to the survey.  It is not passing the unique
id code and course code.  In theory, it should carry that info over
and when survey is submitted the info submitted goes into the db on
the same row as the unique id code.  It enters info on a new row. The
code below is the action script for the survey page.
<?PHP include("../includes/connect.php"); ?>
$classid = $passcid;
$required = $_POST['required'];
$q1 = $_POST['q1'];
$q2 = $_POST['q2'];
$q3 = $_POST['q3'];
$q4 = $_POST['q4'];
$q5 = $_POST['q5'];
$q6 = $_POST['q6'];
$q7 = $_POST['q7'];
$q8 = $_POST['q8'];
$q9 = $_POST['q9'];
$q10 = $_POST['q10'];
$comments = $_POST['comments'];

$sql = "SELECT * FROM $db_table10 WHERE id = '$passid'";
mysql_query ($sql) or die('Query 5 failed because: ' . mysql_error());

$sql2 = " INSERT INTO $db_table10
        (classid, required, q1, q2, q3, q4, q5, q6, q7, q8, q9, q10,
        ('$classid', '$required', '$q1', '$q2', '$q3', '$q4', '$q5',
'$q6', '$q7', '$q8', '$q9', '$q10', '$comments')";
mysql_query ($sql2) or die('Query 6 failed because: ' .

echo "Thank you for completing your course survey.";
The code below is from the survey page.  I did the session start thing
at the beginning.
<TITLE>Lynne Smith - Courses</TITLE>
<?PHP INCLUDE("../includes/headsection.txt")?>

//include varibles from last page
//also need to include semester in db or by timestamp
echo "$passid";
echo "$classid";


<?PHP INCLUDE("../includes/connect.php"); ?>
<DIV ID="wrapper">
<DIV ID="header">

<DIV ID="navigation">
<?PHP INCLUDE("../includes/menu.txt"); ?>
<DIV ID="subnavigation">
<?PHP include("../includes/subnav.txt"); ?>
<DIV ID="content">
<H1 ALIGN="center">End of Class Survey </H1>
<P CLASS="instruct">
<FORM ACTION="adminsubmitsurvey.php" METHOD="post" NAME="survey"
Is this course required for your major?<BR>
<INPUT TYPE="radio" NAME="required" VALUE="yes">Yes<BR>
<INPUT TYPE="radio" NAME="required" VALUE="no">No<BR>
<INPUT TYPE="radio" NAME="required" VALUE="dk">Don't Know<BR>
Also, should I try to check for fields not completed in php or

Re: sessions

up2trouble wrote:
Quoted text here. Click to load it

This doesn't set the session variable to anything.

Quoted text here. Click to load it

Because nowhere in the above script to you actually set

Quoted text here. Click to load it

You never set $passcid.  You need to do a session_start() (at the top of
EVERY page which uses session) and get the value of
$_SESSION['passcid'], i.e.

$passcid = ifset($_SESSION['passcid']) ? $_SESSION['passcid'] : null;

Quoted text here. Click to load it

And you have other problems - for instance, where did you set $classid,
$required, etc.?

Quoted text here. Click to load it

How are you including the variables from the last page?

Quoted text here. Click to load it

I think you have a basic misunderstanding of sessions.  Any page which
uses a session must call session_start() at the beginning of that page.
  Additionally, the data is kept in an array called $_SESSION.  To save
items in the array, you assign a value to a specific index in the
$_SESSION array.  To retrieve the value, you use it from the appropriate
index in the $_SESSION array (or just use the array element itself).

Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.

Re: sessions

Quoted text here. Click to load it

I think I have it working now.  Thanks

Site Timeline