dereksheahan
asked on
POST variable problem
Hi all,
I have a variable created on the page like this:
$member_main_last_id = mysql_insert_id();
(I know this variable works fine because I'm using it to update the DB and it works)
I try to POST it like this:
<input type="hidden" name="member_id" value="<?php echo $member_main_last_id ?>"/>
Then on the next page I try to use it like this:
<?php echo $_POST['member_id']; ?>
Gives me the error:
Notice: Undefined index: member_id in C:\xxx\reg3.php on line 245
Any ideas where I'm going wrong?
Thanks,
D
I have a variable created on the page like this:
$member_main_last_id = mysql_insert_id();
(I know this variable works fine because I'm using it to update the DB and it works)
I try to POST it like this:
<input type="hidden" name="member_id" value="<?php echo $member_main_last_id ?>"/>
Then on the next page I try to use it like this:
<?php echo $_POST['member_id']; ?>
Gives me the error:
Notice: Undefined index: member_id in C:\xxx\reg3.php on line 245
Any ideas where I'm going wrong?
Thanks,
D
ASKER
Yes,
<input type="hidden" name="member_id" value="<?php echo $member_main_last_id ?>"/>
</form>
<input type="hidden" name="member_id" value="<?php echo $member_main_last_id ?>"/>
</form>
can you show the <form ...> tag itself, please.
ASKER
Okay,
<form id="personal_reg" name="personal_reg" method="POST" action="<?php echo $editFormAction; ?>">
<?php echo $_POST['drop_travel'] ?>
<label for="textfield">Personal Details <br />
<br />
</label>
<table width="428" border="1">
<tr>
<td width="191"><label for="lbl_username">Usernam e<br />
<span class="style1">(this is what will be displayed to the users) </span></label></td>
<td width="221"><input type="text" name="txt_username" id="txt_username" /></td>
</tr>
<tr>
<td><label for="lbl_gender">Gender</l abel></td>
<td><select name="select_gender" id="select_gender">
<option value="male">Male</option>
<option value="female">Female</opt ion>
</select></td>
</tr>
<tr>
<td><label for="lbl_password">Passwor d</label>< /td>
<td><input type="password" name="txt_password" id="lbl_password" /></td>
</tr>
<tr>
<td><label for="lbl_re_password">Re-e nter Password</label></td>
<td><input type="password" name="txt_re_password" id="lbl_re_password" /></td>
</tr>
<tr>
<td>Are you willing to travel to students? </td>
<td><label for="lbl_travel"></label>
<select name="drop_travel" id="lbl_travel">
<option value="yes">Yes</option>
<option value="no">No</option>
</select> </td>
</tr>
<tr>
<td><label for="lbl_avail">Availabili ty</label> </td>
<td><textarea name="txt_availabilty" cols="34" rows="3" id="lbl_avail"></textarea> </td>
</tr>
</table>
<p> </p>
<p>Location Details: </p>
<table width="400" border="1">
<tr>
<td>Select your County </td>
<td><select name="County" id="County" onchange="TCN_reload(this) ">
<option selected="selected">County </option>
</select></td>
</tr>
<tr>
<td>Select your Town</td>
<td><select name="Town" id="Town" onchange="TCN_reload(this) ">
<option selected="selected">Town</ option>
</select></td>
</tr>
<tr>
<td><label for="lbl_full_add">Full Address (*)</label></td>
<td><textarea name="txt_full_add" cols="30" rows="3" id="label9"></textarea></t d>
</tr>
<tr>
<td colspan="2"><div align="center">Click <a href="../map/sfliveaddpt.p hp" target="myChildWindow">her e</a> to add your exact address on a map </div></td>
</tr>
</table>
<p>
<script language="JavaScript" type="text/javascript">
TCN_contents=new Array();
TCN_tempArray=new Array();
TCN_counter=0;
function TCN_addContent(str){
TCN_contents[TCN_counter]= str;
TCN_counter++;
}
function TCN_split(){
TCN_arrayValues = new Array();
for(i=0;i<TCN_contents.len gth;i++){
TCN_arrayValues[i]=TCN_con tents[i].s plit(separ ator);
TCN_tempArray[0]=TCN_array Values;
}
}
function TCN_makeSelValueGroup(){
TCN_selValueGroup=new Array();
var args=TCN_makeSelValueGroup .arguments ;
for(i=0;i<args.length;i++) {
TCN_selValueGroup[i]=args[ i];
TCN_tempArray[i]=new Array();
}
}
function TCN_makeComboGroup(){
TCN_comboGroup=new Array();
var args=TCN_makeComboGroup.ar guments;
for(i=0;i<args.length;i++) TCN_comboGroup[i]=findObj( args[i]);
}
function TCN_setDefault(){
for (i=TCN_selValueGroup.lengt h-1;i>=0;i --){
if(TCN_selValueGroup[i]!=" "){
for(j=0;j<TCN_contents.len gth;j++){
if(TCN_arrayValues[j][(i*2 )+1]==TCN_ selValueGr oup[i]){
for(k=i;k>=0;k--){
if(TCN_selValueGroup[k]==" ") TCN_selValueGroup[k]=TCN_a rrayValues [j][(k*2)+ 1];
}
}
}
}
}
}
function TCN_loadMenu(daIndex){
var selectionMade=false;
daArray=TCN_tempArray[daIn dex];
TCN_comboGroup[daIndex].op tions.leng th=0;
for(i=0;i<daArray.length;i ++){
existe=false;
for(j=0;j<TCN_comboGroup[d aIndex].op tions.leng th;j++){
if(daArray[i][(daIndex*2)+ 1]==TCN_co mboGroup[d aIndex].op tions[j].v alue) existe=true;
}
if(existe==false){
lastValue=TCN_comboGroup[d aIndex].op tions.leng th;
TCN_comboGroup[daIndex].op tions[TCN_ comboGroup [daIndex]. options.le ngth]=new Option(daArray[i][daIndex* 2],daArray [i][(daInd ex*2)+1]);
if(TCN_selValueGroup[daInd ex]==TCN_c omboGroup[ daIndex].o ptions[las tValue].va lue){
TCN_comboGroup[daIndex].op tions[last Value].sel ected=true ;
selectionMade=true;
}
}
}
if(selectionMade==false) TCN_comboGroup[daIndex].op tions[0].s elected=tr ue;
}
function TCN_reload(from){
if(!from){
TCN_split();
TCN_setDefault();
TCN_loadMenu(0);
TCN_reload(TCN_comboGroup[ 0]);
}else{
for(j=0; j<TCN_comboGroup.length; j++){
if(TCN_comboGroup[j]==from ) index=j+1;
}
if(index<TCN_comboGroup.le ngth){
TCN_tempArray[index].lengt h=0;
for(i=0;i<TCN_comboGroup[i ndex-1].op tions.leng th;i++){
if(TCN_comboGroup[index-1] .options[i ].selected ==true){
for(j=0;j<TCN_tempArray[in dex-1].len gth;j++){
if(TCN_comboGroup[index-1] .options[i ].value==T CN_tempArr ay[index-1 ][j][(inde x*2)-1]) TCN_tempArray[index][TCN_t empArray[i ndex].leng th]=TCN_te mpArray[in dex-1][j];
}
}
}
TCN_loadMenu(index);
TCN_reload(TCN_comboGroup[ index]);
}
}
}
function findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&p arent.fram es.length) {
d=parent.frames[n.substrin g(p+1)].do cument; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length; i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d. layers.len gth;i++) x=findObj(n,d.layers[i].do cument);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}
TCN_makeSelValueGroup(""," ");
TCN_makeComboGroup("County ","Town");
var separator="+#+";
<?php do{?>
TCN_addContent("<?php echo $row_rscounty_town['c_coun ty_name']; ?>+#+<?php echo $row_rscounty_town['c_coun ty_id']; ?>+#+<?php echo $row_rscounty_town['t_town _name']; ?>+#+<?php echo $row_rscounty_town['t_town _id']; ?>");
<?php } while ($row_rscounty_town = mysql_fetch_assoc($rscount y_town)); ?>
TCN_reload();
</script>
</p>
<p>
<label for="lbl_lat">Latitude</la bel>
<input type="text" name="latitude" id="latitude" value="<?php echo htmlspecialchars($_POST['n ew_lat']); ?>" />
</p>
<p>
<label for="lbl_long">Longitude</ label>
<input type="text" name="longitude" id="longitude" value="<?php echo htmlspecialchars($_POST['n ew_lon']); ?>" />
</p>
<p>Contact Details: </p>
<table width="400" border="1">
<tr>
<td><label for="lbl_num1">Contact Number</label></td>
<td><input type="text" name="txt_num1" id="txt_num1" /></td>
</tr>
<tr>
<td><label for="lbl_num2">Contact Number 2 * </label></td>
<td><input type="text" name="txt_num2" id="txt_num2" /></td>
</tr>
<tr>
<td><label for="lbl_email_add">Email Address</label></td>
<td><input type="text" name="txt_email_add" id="txt_email_add" /></td>
</tr>
<tr>
<td><label for="lbl_web_add">Website Address * </label></td>
<td><input type="text" name="txt_web" id="txt_web" /></td>
</tr>
</table>
<p> </p>
<p>
<label for="Submit">Proceed to Subject Information</label>
<input type="submit" name="Submit" value="Proceed" id="Submit" />
<label for="label10"></label>
</p>
<input type="hidden" name="MM_insert" value="personal_reg"/>
<input type="hidden" name="teacher_type" value="<?php echo $_POST['cat_select'] ?>"/>
<input type="hidden" name="member_id" value="<?php echo $member_main_last_id ?>"/>
</form>
<form id="personal_reg" name="personal_reg" method="POST" action="<?php echo $editFormAction; ?>">
<?php echo $_POST['drop_travel'] ?>
<label for="textfield">Personal Details <br />
<br />
</label>
<table width="428" border="1">
<tr>
<td width="191"><label for="lbl_username">Usernam
<span class="style1">(this is what will be displayed to the users) </span></label></td>
<td width="221"><input type="text" name="txt_username" id="txt_username" /></td>
</tr>
<tr>
<td><label for="lbl_gender">Gender</l
<td><select name="select_gender" id="select_gender">
<option value="male">Male</option>
<option value="female">Female</opt
</select></td>
</tr>
<tr>
<td><label for="lbl_password">Passwor
<td><input type="password" name="txt_password" id="lbl_password" /></td>
</tr>
<tr>
<td><label for="lbl_re_password">Re-e
<td><input type="password" name="txt_re_password" id="lbl_re_password" /></td>
</tr>
<tr>
<td>Are you willing to travel to students? </td>
<td><label for="lbl_travel"></label>
<select name="drop_travel" id="lbl_travel">
<option value="yes">Yes</option>
<option value="no">No</option>
</select> </td>
</tr>
<tr>
<td><label for="lbl_avail">Availabili
<td><textarea name="txt_availabilty" cols="34" rows="3" id="lbl_avail"></textarea>
</tr>
</table>
<p> </p>
<p>Location Details: </p>
<table width="400" border="1">
<tr>
<td>Select your County </td>
<td><select name="County" id="County" onchange="TCN_reload(this)
<option selected="selected">County
</select></td>
</tr>
<tr>
<td>Select your Town</td>
<td><select name="Town" id="Town" onchange="TCN_reload(this)
<option selected="selected">Town</
</select></td>
</tr>
<tr>
<td><label for="lbl_full_add">Full Address (*)</label></td>
<td><textarea name="txt_full_add" cols="30" rows="3" id="label9"></textarea></t
</tr>
<tr>
<td colspan="2"><div align="center">Click <a href="../map/sfliveaddpt.p
</tr>
</table>
<p>
<script language="JavaScript" type="text/javascript">
TCN_contents=new Array();
TCN_tempArray=new Array();
TCN_counter=0;
function TCN_addContent(str){
TCN_contents[TCN_counter]=
TCN_counter++;
}
function TCN_split(){
TCN_arrayValues = new Array();
for(i=0;i<TCN_contents.len
TCN_arrayValues[i]=TCN_con
TCN_tempArray[0]=TCN_array
}
}
function TCN_makeSelValueGroup(){
TCN_selValueGroup=new Array();
var args=TCN_makeSelValueGroup
for(i=0;i<args.length;i++)
TCN_selValueGroup[i]=args[
TCN_tempArray[i]=new Array();
}
}
function TCN_makeComboGroup(){
TCN_comboGroup=new Array();
var args=TCN_makeComboGroup.ar
for(i=0;i<args.length;i++)
}
function TCN_setDefault(){
for (i=TCN_selValueGroup.lengt
if(TCN_selValueGroup[i]!="
for(j=0;j<TCN_contents.len
if(TCN_arrayValues[j][(i*2
for(k=i;k>=0;k--){
if(TCN_selValueGroup[k]=="
}
}
}
}
}
}
function TCN_loadMenu(daIndex){
var selectionMade=false;
daArray=TCN_tempArray[daIn
TCN_comboGroup[daIndex].op
for(i=0;i<daArray.length;i
existe=false;
for(j=0;j<TCN_comboGroup[d
if(daArray[i][(daIndex*2)+
}
if(existe==false){
lastValue=TCN_comboGroup[d
TCN_comboGroup[daIndex].op
if(TCN_selValueGroup[daInd
TCN_comboGroup[daIndex].op
selectionMade=true;
}
}
}
if(selectionMade==false) TCN_comboGroup[daIndex].op
}
function TCN_reload(from){
if(!from){
TCN_split();
TCN_setDefault();
TCN_loadMenu(0);
TCN_reload(TCN_comboGroup[
}else{
for(j=0; j<TCN_comboGroup.length; j++){
if(TCN_comboGroup[j]==from
}
if(index<TCN_comboGroup.le
TCN_tempArray[index].lengt
for(i=0;i<TCN_comboGroup[i
if(TCN_comboGroup[index-1]
for(j=0;j<TCN_tempArray[in
if(TCN_comboGroup[index-1]
}
}
}
TCN_loadMenu(index);
TCN_reload(TCN_comboGroup[
}
}
}
function findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&p
d=parent.frames[n.substrin
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;
for(i=0;!x&&d.layers&&i<d.
if(!x && d.getElementById) x=d.getElementById(n); return x;
}
TCN_makeSelValueGroup("","
TCN_makeComboGroup("County
var separator="+#+";
<?php do{?>
TCN_addContent("<?php echo $row_rscounty_town['c_coun
<?php } while ($row_rscounty_town = mysql_fetch_assoc($rscount
TCN_reload();
</script>
</p>
<p>
<label for="lbl_lat">Latitude</la
<input type="text" name="latitude" id="latitude" value="<?php echo htmlspecialchars($_POST['n
</p>
<p>
<label for="lbl_long">Longitude</
<input type="text" name="longitude" id="longitude" value="<?php echo htmlspecialchars($_POST['n
</p>
<p>Contact Details: </p>
<table width="400" border="1">
<tr>
<td><label for="lbl_num1">Contact Number</label></td>
<td><input type="text" name="txt_num1" id="txt_num1" /></td>
</tr>
<tr>
<td><label for="lbl_num2">Contact Number 2 * </label></td>
<td><input type="text" name="txt_num2" id="txt_num2" /></td>
</tr>
<tr>
<td><label for="lbl_email_add">Email Address</label></td>
<td><input type="text" name="txt_email_add" id="txt_email_add" /></td>
</tr>
<tr>
<td><label for="lbl_web_add">Website Address * </label></td>
<td><input type="text" name="txt_web" id="txt_web" /></td>
</tr>
</table>
<p> </p>
<p>
<label for="Submit">Proceed to Subject Information</label>
<input type="submit" name="Submit" value="Proceed" id="Submit" />
<label for="label10"></label>
</p>
<input type="hidden" name="MM_insert" value="personal_reg"/>
<input type="hidden" name="teacher_type" value="<?php echo $_POST['cat_select'] ?>"/>
<input type="hidden" name="member_id" value="<?php echo $member_main_last_id ?>"/>
</form>
ASKER
sorry Angel,
perhaps it would be better if I posted the entire page if the variable is coming from the php above the form. Here is the php part:
<?php require_once('../Connectio ns/reacha_ new.php'); ?>
<?php
function GetSQLValueString($theValu e, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STR ING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUE RY_STRING' ]);
}
if ((isset($_POST["MM_insert" ])) && ($_POST["MM_insert"] == "personal_reg")) {
$insertSQL = sprintf("INSERT INTO member_main (mm_username, mm_full_address, mm_travel, mm_mem_type_id, mm_password, mm_native_town_id, mm_contact_nr, mm_contact_nr_alt, mm_email_add, mm_website_add, mm_lat, mm_long, mm_start_date) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, now())",
GetSQLValueString($_POST[' txt_userna me'], "text"),
GetSQLValueString($_POST[' txt_full_a dd'], "text"),
GetSQLValueString($_POST[' drop_trave l'], "text"),
GetSQLValueString($_POST[' teacher_ty pe'], "int"),
GetSQLValueString($_POST[' txt_passwo rd'], "text"),
GetSQLValueString($_POST[' Town'], "int"),
GetSQLValueString($_POST[' txt_num1'] , "int"),
GetSQLValueString($_POST[' txt_num2'] , "int"),
GetSQLValueString($_POST[' txt_email_ add'], "text"),
GetSQLValueString($_POST[' txt_web'], "text"),
GetSQLValueString($_POST[' latitude'] , "double"),
GetSQLValueString($_POST[' longitude' ], "double"));
mysql_select_db($database_ reacha_new , $reacha_new);
$Result1 = mysql_query($insertSQL, $reacha_new) or die(mysql_error());
}
$member_main_last_id = mysql_insert_id();
if ((isset($_POST["MM_insert" ])) && ($_POST["MM_insert"] == "personal_reg")) {
$insertSQL = sprintf("INSERT INTO member_per (mp_mem_id, mp_gender, mp_availability) VALUES (%s, %s, %s)",
GetSQLValueString($member_ main_last_ id, "int"),
GetSQLValueString($_POST[' select_gen der'], "text"),
GetSQLValueString($_POST[' txt_availa bilty'], "text"));
mysql_select_db($database_ reacha_new , $reacha_new);
$Result1 = mysql_query($insertSQL, $reacha_new) or die(mysql_error());
$insertGoTo = "../Registration/reg3per.p hp";
if (isset($_SERVER['QUERY_STR ING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
//require_once('../Connect ions/reach a_new.php' ); ?>
<?php
mysql_select_db($database_ reacha_new , $reacha_new);
$query_rscounty_town = "SELECT county.c_county_id, county.c_county_name, town.t_town_id, town.t_town_name, town.t_lat, town.t_lon, town.t_county_id FROM county, town WHERE town.t_county_id = county.c_county_id";
$rscounty_town = mysql_query($query_rscount y_town, $reacha_new) or die(mysql_error());
$row_rscounty_town = mysql_fetch_assoc($rscount y_town);
$totalRows_rscounty_town = mysql_num_rows($rscounty_t own);
?>
Thanks for your time,
D
perhaps it would be better if I posted the entire page if the variable is coming from the php above the form. Here is the php part:
<?php require_once('../Connectio
<?php
function GetSQLValueString($theValu
{
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STR
$editFormAction .= "?" . htmlentities($_SERVER['QUE
}
if ((isset($_POST["MM_insert"
$insertSQL = sprintf("INSERT INTO member_main (mm_username, mm_full_address, mm_travel, mm_mem_type_id, mm_password, mm_native_town_id, mm_contact_nr, mm_contact_nr_alt, mm_email_add, mm_website_add, mm_lat, mm_long, mm_start_date) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, now())",
GetSQLValueString($_POST['
GetSQLValueString($_POST['
GetSQLValueString($_POST['
GetSQLValueString($_POST['
GetSQLValueString($_POST['
GetSQLValueString($_POST['
GetSQLValueString($_POST['
GetSQLValueString($_POST['
GetSQLValueString($_POST['
GetSQLValueString($_POST['
GetSQLValueString($_POST['
GetSQLValueString($_POST['
mysql_select_db($database_
$Result1 = mysql_query($insertSQL, $reacha_new) or die(mysql_error());
}
$member_main_last_id = mysql_insert_id();
if ((isset($_POST["MM_insert"
$insertSQL = sprintf("INSERT INTO member_per (mp_mem_id, mp_gender, mp_availability) VALUES (%s, %s, %s)",
GetSQLValueString($member_
GetSQLValueString($_POST['
GetSQLValueString($_POST['
mysql_select_db($database_
$Result1 = mysql_query($insertSQL, $reacha_new) or die(mysql_error());
$insertGoTo = "../Registration/reg3per.p
if (isset($_SERVER['QUERY_STR
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
//require_once('../Connect
<?php
mysql_select_db($database_
$query_rscounty_town = "SELECT county.c_county_id, county.c_county_name, town.t_town_id, town.t_town_name, town.t_lat, town.t_lon, town.t_county_id FROM county, town WHERE town.t_county_id = county.c_county_id";
$rscounty_town = mysql_query($query_rscount
$row_rscounty_town = mysql_fetch_assoc($rscount
$totalRows_rscounty_town = mysql_num_rows($rscounty_t
?>
Thanks for your time,
D
can't you simply check out the html source code before hitting submit button?
the code you posted looks right at first skimming
the code you posted looks right at first skimming
ASKER
good point ThG,
Yes it looks correct:
<input type="hidden" name="member_id" value="29"/>
So it must be something on the recieving page that's causing it?
Here's the source if you have a couple of mins to take a look :)
Thanks so much,
D
<?php require_once('../Connectio ns/reacha_ new.php'); ?>
<?php
ini_set('error_reporting', E_ALL);
ini_set('display_errors', 'On');
ini_set('display_startup_e rrors', 'On');
mysql_select_db($database_ reacha_new , $reacha_new);
$query_rsSubjects = "SELECT main_cat.mc_cat_id, main_cat.mc_cat_type, sub_cat.sc_sub_cat_id, sub_cat.sc_sub_cat_name, sub_cat.sc_cat_id, subject.s_subject_id, subject.s_subject_name, subject.s_sub_cat_id FROM main_cat, sub_cat, subject WHERE subject.s_sub_cat_id = sub_cat.sc_sub_cat_id AND sub_cat.sc_cat_id = main_cat.mc_cat_id";
$rsSubjects = mysql_query($query_rsSubje cts, $reacha_new) or die(mysql_error());
$row_rsSubjects = mysql_fetch_assoc($rsSubje cts);
$totalRows_rsSubjects = mysql_num_rows($rsSubjects );
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<style type="text/css">
<!--
#Layer1 {
position:absolute;
left:53px;
top:77px;
width:483px;
height:217px;
z-index:1;
}
#Layer2 {
position:absolute;
left:386px;
top:116px;
width:348px;
height:218px;
z-index:2;
}
#Chosen {
position:absolute;
left:566px;
top:116px;
width:188px;
height:154px;
z-index:2;
background-color: #66FF33;
}
#Layer3 {
position:absolute;
left:563px;
top:89px;
width:192px;
height:24px;
z-index:3;
}
#Layer4 {
position:absolute;
width:70px;
height:29px;
z-index:4;
left: 557px;
top: 293px;
}
-->
</style>
<script language="javascript" type="text/javascript">
var activities = new Array() //Make sure this is outside of any functions!!
function addActivity(select){
var div;
var addIt = true;
if(select!=undefined){
value = select.value.split(':');
for(var x in activities){
if(activities[x][0]==value [0]){
addIt = false;
}
}
if(addIt==true){
activities.splice(activiti es.length, 0,new Array());
activities[activities.leng th - 1][0] = value[0];
activities[activities.leng th - 1][1] = value[1];
}
}
document.form1.activityId. value = ''
document.getElementById('C hosen').in nerHTML = ''
for(var x in activities){
div = '<div id="' + activities[x][0] + '" ondblclick="removeActivity (this.id)" >' + activities[x][1] + '</div>';
if(x>0){
document.form1.activityId. value = document.form1.activityId. value + ',' + activities[x][0];
document.getElementById('C hosen').in nerHTML = document.getElementById('C hosen').in nerHTML + div;
}
else{
document.form1.activityId. value = activities[x][0];
document.getElementById('C hosen').in nerHTML = div;
}
}
}
function removeActivity(id){
for(var x in activities){
if(activities[x][0]==id){
activities.splice(x,1);
}
}
addActivity();
}
function clearAll(){
activities.splice(0,activi ties.lengt h);
document.getElementById('C hosen').in nerHTML = '';
document.form1.activityId. value = '';
}
</script>
</head>
<body>
<div id="Layer1">
<form id="form1" name="form1" method="post" action="reg4per.php">
<?php $mem_id = 5; ?>
<input type="hidden" name="mem_id" value="<?php echo $mem_id ?>">
<p>
<select name="Main Cat" id="Main Cat" onchange="TCN_reload(this) ">
<option selected="selected">Main Cat</option>
</select>
<select name="Sub Cat" id="Sub Cat" onchange="TCN_reload(this) ">
<option selected="selected">Sub Cat</option>
</select>
</p>
<p>
<select name="Subjects" size="5" multiple="multiple" id="Subjects" onchange="TCN_reload(this) " ondblclick="addActivity(th is)">
<option selected="selected">Subjec ts</option >
</select>
<script language="JavaScript" type="text/javascript">
TCN_contents=new Array();
TCN_tempArray=new Array();
TCN_counter=0;
function TCN_addContent(str){
TCN_contents[TCN_counter]= str;
TCN_counter++;
}
function TCN_split(){
TCN_arrayValues = new Array();
for(i=0;i<TCN_contents.len gth;i++){
TCN_arrayValues[i]=TCN_con tents[i].s plit(separ ator);
TCN_tempArray[0]=TCN_array Values;
}
}
function TCN_makeSelValueGroup(){
TCN_selValueGroup=new Array();
var args=TCN_makeSelValueGroup .arguments ;
for(i=0;i<args.length;i++) {
TCN_selValueGroup[i]=args[ i];
TCN_tempArray[i]=new Array();
}
}
function TCN_makeComboGroup(){
TCN_comboGroup=new Array();
var args=TCN_makeComboGroup.ar guments;
for(i=0;i<args.length;i++) TCN_comboGroup[i]=findObj( args[i]);
}
function TCN_setDefault(){
for (i=TCN_selValueGroup.lengt h-1;i>=0;i --){
if(TCN_selValueGroup[i]!=" "){
for(j=0;j<TCN_contents.len gth;j++){
if(TCN_arrayValues[j][(i*2 )+1]==TCN_ selValueGr oup[i]){
for(k=i;k>=0;k--){
if(TCN_selValueGroup[k]==" ") TCN_selValueGroup[k]=TCN_a rrayValues [j][(k*2)+ 1];
}
}
}
}
}
}
function TCN_loadMenu(daIndex){
var selectionMade=false;
daArray=TCN_tempArray[daIn dex];
TCN_comboGroup[daIndex].op tions.leng th=0;
for(i=0;i<daArray.length;i ++){
existe=false;
for(j=0;j<TCN_comboGroup[d aIndex].op tions.leng th;j++){
if(daArray[i][(daIndex*2)+ 1]==TCN_co mboGroup[d aIndex].op tions[j].v alue) existe=true;
}
if(existe==false){
lastValue=TCN_comboGroup[d aIndex].op tions.leng th;
TCN_comboGroup[daIndex].op tions[TCN_ comboGroup [daIndex]. options.le ngth]=new Option(daArray[i][daIndex* 2],daArray [i][(daInd ex*2)+1]);
if(TCN_selValueGroup[daInd ex]==TCN_c omboGroup[ daIndex].o ptions[las tValue].va lue){
TCN_comboGroup[daIndex].op tions[last Value].sel ected=true ;
selectionMade=true;
}
}
}
if(selectionMade==false) TCN_comboGroup[daIndex].op tions[0].s elected=tr ue;
}
function TCN_reload(from){
if(!from){
TCN_split();
TCN_setDefault();
TCN_loadMenu(0);
TCN_reload(TCN_comboGroup[ 0]);
}else{
for(j=0; j<TCN_comboGroup.length; j++){
if(TCN_comboGroup[j]==from ) index=j+1;
}
if(index<TCN_comboGroup.le ngth){
TCN_tempArray[index].lengt h=0;
for(i=0;i<TCN_comboGroup[i ndex-1].op tions.leng th;i++){
if(TCN_comboGroup[index-1] .options[i ].selected ==true){
for(j=0;j<TCN_tempArray[in dex-1].len gth;j++){
if(TCN_comboGroup[index-1] .options[i ].value==T CN_tempArr ay[index-1 ][j][(inde x*2)-1]) TCN_tempArray[index][TCN_t empArray[i ndex].leng th]=TCN_te mpArray[in dex-1][j];
}
}
}
TCN_loadMenu(index);
TCN_reload(TCN_comboGroup[ index]);
}
}
}
function findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&p arent.fram es.length) {
d=parent.frames[n.substrin g(p+1)].do cument; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length; i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d. layers.len gth;i++) x=findObj(n,d.layers[i].do cument);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}
TCN_makeSelValueGroup(""," ","");
TCN_makeComboGroup("Main Cat","Sub Cat","Subjects");
var separator="+#+";
<?php do{?>
TCN_addContent("<?php echo $row_rsSubjects['mc_cat_ty pe']; ?>+#+<?php echo $row_rsSubjects['mc_cat_id ']; ?>+#+<?php echo $row_rsSubjects['sc_sub_ca t_name']; ?>+#+<?php echo $row_rsSubjects['sc_sub_ca t_id']; ?>+#+<?php echo $row_rsSubjects['s_subject _name']; ?>+#+<?php echo $row_rsSubjects['s_subject _id'].":"; ?><?php echo $row_rsSubjects['s_subject _name']; ?>");
<?php } while ($row_rsSubjects = mysql_fetch_assoc($rsSubje cts)); ?>
TCN_reload();
</script>
<input type="button" id="removeButton" style="display: none" value="Remove!" onclick="removeActivity()" />
</p>
<p>
<input type="text" name="activityId" id="activityId" value=""/>
</p>
<p>
<label for="Submit">Proceed</labe l>
<input type="submit" name="Submit" value="Submit" id="Submit" />
</p>
<?php echo $_POST['member_id'] ?>
</form>
</div>
<div id="Chosen">
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
</div>
<div id="Layer3">Your Chosen Subjects: </div>
<div id="Layer4">
<input name="button" type="button" onclick="clearAll()" value="Clear All!" /></div>
</body>
</html>
<?php
mysql_free_result($rsSubje cts);
?>
Yes it looks correct:
<input type="hidden" name="member_id" value="29"/>
So it must be something on the recieving page that's causing it?
Here's the source if you have a couple of mins to take a look :)
Thanks so much,
D
<?php require_once('../Connectio
<?php
ini_set('error_reporting',
ini_set('display_errors', 'On');
ini_set('display_startup_e
mysql_select_db($database_
$query_rsSubjects = "SELECT main_cat.mc_cat_id, main_cat.mc_cat_type, sub_cat.sc_sub_cat_id, sub_cat.sc_sub_cat_name, sub_cat.sc_cat_id, subject.s_subject_id, subject.s_subject_name, subject.s_sub_cat_id FROM main_cat, sub_cat, subject WHERE subject.s_sub_cat_id = sub_cat.sc_sub_cat_id AND sub_cat.sc_cat_id = main_cat.mc_cat_id";
$rsSubjects = mysql_query($query_rsSubje
$row_rsSubjects = mysql_fetch_assoc($rsSubje
$totalRows_rsSubjects = mysql_num_rows($rsSubjects
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<style type="text/css">
<!--
#Layer1 {
position:absolute;
left:53px;
top:77px;
width:483px;
height:217px;
z-index:1;
}
#Layer2 {
position:absolute;
left:386px;
top:116px;
width:348px;
height:218px;
z-index:2;
}
#Chosen {
position:absolute;
left:566px;
top:116px;
width:188px;
height:154px;
z-index:2;
background-color: #66FF33;
}
#Layer3 {
position:absolute;
left:563px;
top:89px;
width:192px;
height:24px;
z-index:3;
}
#Layer4 {
position:absolute;
width:70px;
height:29px;
z-index:4;
left: 557px;
top: 293px;
}
-->
</style>
<script language="javascript" type="text/javascript">
var activities = new Array() //Make sure this is outside of any functions!!
function addActivity(select){
var div;
var addIt = true;
if(select!=undefined){
value = select.value.split(':');
for(var x in activities){
if(activities[x][0]==value
addIt = false;
}
}
if(addIt==true){
activities.splice(activiti
activities[activities.leng
activities[activities.leng
}
}
document.form1.activityId.
document.getElementById('C
for(var x in activities){
div = '<div id="' + activities[x][0] + '" ondblclick="removeActivity
if(x>0){
document.form1.activityId.
document.getElementById('C
}
else{
document.form1.activityId.
document.getElementById('C
}
}
}
function removeActivity(id){
for(var x in activities){
if(activities[x][0]==id){
activities.splice(x,1);
}
}
addActivity();
}
function clearAll(){
activities.splice(0,activi
document.getElementById('C
document.form1.activityId.
}
</script>
</head>
<body>
<div id="Layer1">
<form id="form1" name="form1" method="post" action="reg4per.php">
<?php $mem_id = 5; ?>
<input type="hidden" name="mem_id" value="<?php echo $mem_id ?>">
<p>
<select name="Main Cat" id="Main Cat" onchange="TCN_reload(this)
<option selected="selected">Main Cat</option>
</select>
<select name="Sub Cat" id="Sub Cat" onchange="TCN_reload(this)
<option selected="selected">Sub Cat</option>
</select>
</p>
<p>
<select name="Subjects" size="5" multiple="multiple" id="Subjects" onchange="TCN_reload(this)
<option selected="selected">Subjec
</select>
<script language="JavaScript" type="text/javascript">
TCN_contents=new Array();
TCN_tempArray=new Array();
TCN_counter=0;
function TCN_addContent(str){
TCN_contents[TCN_counter]=
TCN_counter++;
}
function TCN_split(){
TCN_arrayValues = new Array();
for(i=0;i<TCN_contents.len
TCN_arrayValues[i]=TCN_con
TCN_tempArray[0]=TCN_array
}
}
function TCN_makeSelValueGroup(){
TCN_selValueGroup=new Array();
var args=TCN_makeSelValueGroup
for(i=0;i<args.length;i++)
TCN_selValueGroup[i]=args[
TCN_tempArray[i]=new Array();
}
}
function TCN_makeComboGroup(){
TCN_comboGroup=new Array();
var args=TCN_makeComboGroup.ar
for(i=0;i<args.length;i++)
}
function TCN_setDefault(){
for (i=TCN_selValueGroup.lengt
if(TCN_selValueGroup[i]!="
for(j=0;j<TCN_contents.len
if(TCN_arrayValues[j][(i*2
for(k=i;k>=0;k--){
if(TCN_selValueGroup[k]=="
}
}
}
}
}
}
function TCN_loadMenu(daIndex){
var selectionMade=false;
daArray=TCN_tempArray[daIn
TCN_comboGroup[daIndex].op
for(i=0;i<daArray.length;i
existe=false;
for(j=0;j<TCN_comboGroup[d
if(daArray[i][(daIndex*2)+
}
if(existe==false){
lastValue=TCN_comboGroup[d
TCN_comboGroup[daIndex].op
if(TCN_selValueGroup[daInd
TCN_comboGroup[daIndex].op
selectionMade=true;
}
}
}
if(selectionMade==false) TCN_comboGroup[daIndex].op
}
function TCN_reload(from){
if(!from){
TCN_split();
TCN_setDefault();
TCN_loadMenu(0);
TCN_reload(TCN_comboGroup[
}else{
for(j=0; j<TCN_comboGroup.length; j++){
if(TCN_comboGroup[j]==from
}
if(index<TCN_comboGroup.le
TCN_tempArray[index].lengt
for(i=0;i<TCN_comboGroup[i
if(TCN_comboGroup[index-1]
for(j=0;j<TCN_tempArray[in
if(TCN_comboGroup[index-1]
}
}
}
TCN_loadMenu(index);
TCN_reload(TCN_comboGroup[
}
}
}
function findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&p
d=parent.frames[n.substrin
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;
for(i=0;!x&&d.layers&&i<d.
if(!x && d.getElementById) x=d.getElementById(n); return x;
}
TCN_makeSelValueGroup("","
TCN_makeComboGroup("Main Cat","Sub Cat","Subjects");
var separator="+#+";
<?php do{?>
TCN_addContent("<?php echo $row_rsSubjects['mc_cat_ty
<?php } while ($row_rsSubjects = mysql_fetch_assoc($rsSubje
TCN_reload();
</script>
<input type="button" id="removeButton" style="display: none" value="Remove!" onclick="removeActivity()"
</p>
<p>
<input type="text" name="activityId" id="activityId" value=""/>
</p>
<p>
<label for="Submit">Proceed</labe
<input type="submit" name="Submit" value="Submit" id="Submit" />
</p>
<?php echo $_POST['member_id'] ?>
</form>
</div>
<div id="Chosen">
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
</div>
<div id="Layer3">Your Chosen Subjects: </div>
<div id="Layer4">
<input name="button" type="button" onclick="clearAll()" value="Clear All!" /></div>
</body>
</html>
<?php
mysql_free_result($rsSubje
?>
well i can't think of any reason it could give that error. are you sure you are not doing any redirects? are you messing with $_POST variable?
you could try with $_REQUEST, it's a copy of $_GET + $_POST + others, but if you are messing with global $_POST at least you have a copy in $_REQUEST['member_id'];
also you could try adding var_dump($_POST) at the top of your form's target script.. to find out what's going on
you could try with $_REQUEST, it's a copy of $_GET + $_POST + others, but if you are messing with global $_POST at least you have a copy in $_REQUEST['member_id'];
also you could try adding var_dump($_POST) at the top of your form's target script.. to find out what's going on
ASKER
Hi,
REQUEST gives the same error.
The error prints:
array(0) { }
..so nothing is in it?
It might have something to do with this. On the sending page I'm using the PHP_SELF action in the form after DB insertion I use:
$insertGoTo = "../Registration/reg3per.p hp";
if (isset($_SERVER['QUERY_STR ING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
could this be nulling the variable?
Thanks,
D
REQUEST gives the same error.
The error prints:
array(0) { }
..so nothing is in it?
It might have something to do with this. On the sending page I'm using the PHP_SELF action in the form after DB insertion I use:
$insertGoTo = "../Registration/reg3per.p
if (isset($_SERVER['QUERY_STR
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
could this be nulling the variable?
Thanks,
D
>>header(sprintf("Location : %s", $insertGoTo));
>could this be nulling the variable?
yes, as then the $_POST get's cleared, as the $_POST is not part ot the QUERY_STRING (AFAIK)
you will have to pass the needed values to $_SESSION for example (that is what I do, but that is not a expert's level )
>could this be nulling the variable?
yes, as then the $_POST get's cleared, as the $_POST is not part ot the QUERY_STRING (AFAIK)
you will have to pass the needed values to $_SESSION for example (that is what I do, but that is not a expert's level )
ASKER
Hi angel,
How would I pass this value to $_SESSION?
Thanks for your help,
D
How would I pass this value to $_SESSION?
Thanks for your help,
D
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi angel,
Still gives the error:
Notice: Undefined variable: _SESSION in C:\xxx\reg3per.php on line 247
Thanks again,
D
Still gives the error:
Notice: Undefined variable: _SESSION in C:\xxx\reg3per.php on line 247
Thanks again,
D
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Great, thanks mach-. I have to put the session_start() on both pages?
Thanks,
D
Thanks,
D
Yes, you must call session_start() on every page that you use a session variable.
does the <input...> variable take part of the <form ...> </form> that get's submitted?