• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 775
  • Last Modified:

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
0
dereksheahan
Asked:
dereksheahan
  • 8
  • 4
  • 2
  • +1
2 Solutions
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
>Then on the next page I try to use it like this:
does the <input...> variable take part of the <form ...> </form> that get's submitted?
0
 
dereksheahanAuthor Commented:
Yes,
<input type="hidden" name="member_id" value="<?php echo $member_main_last_id ?>"/>
</form>
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
can you show the <form ...> tag itself, please.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
dereksheahanAuthor Commented:
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">Username<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</label></td>
      <td><select name="select_gender" id="select_gender">
        <option value="male">Male</option>
        <option value="female">Female</option>
      </select></td>
    </tr>
    <tr>
      <td><label for="lbl_password">Password</label></td>
      <td><input type="password" name="txt_password" id="lbl_password"  /></td>
    </tr>
    <tr>
      <td><label for="lbl_re_password">Re-enter 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">Availability</label></td>
      <td><textarea name="txt_availabilty" cols="34" rows="3" id="lbl_avail"></textarea></td>
    </tr>
  </table>
 

    <p>&nbsp;</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></td>
      </tr>
      <tr>
        <td colspan="2"><div align="center">Click <a href="../map/sfliveaddpt.php" target="myChildWindow">here</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.length;i++){
            TCN_arrayValues[i]=TCN_contents[i].split(separator);
            TCN_tempArray[0]=TCN_arrayValues;
      }
}
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.arguments;
      for(i=0;i<args.length;i++) TCN_comboGroup[i]=findObj(args[i]);
}
function TCN_setDefault(){
      for (i=TCN_selValueGroup.length-1;i>=0;i--){
            if(TCN_selValueGroup[i]!=""){
                  for(j=0;j<TCN_contents.length;j++){
                        if(TCN_arrayValues[j][(i*2)+1]==TCN_selValueGroup[i]){
                              for(k=i;k>=0;k--){
                                    if(TCN_selValueGroup[k]=="") TCN_selValueGroup[k]=TCN_arrayValues[j][(k*2)+1];
                              }
                        }
                  }
            }
      }
}
function TCN_loadMenu(daIndex){
      var selectionMade=false;
      daArray=TCN_tempArray[daIndex];
      TCN_comboGroup[daIndex].options.length=0;
      for(i=0;i<daArray.length;i++){
            existe=false;
            for(j=0;j<TCN_comboGroup[daIndex].options.length;j++){
                  if(daArray[i][(daIndex*2)+1]==TCN_comboGroup[daIndex].options[j].value) existe=true;
            }
            if(existe==false){
                  lastValue=TCN_comboGroup[daIndex].options.length;
                  TCN_comboGroup[daIndex].options[TCN_comboGroup[daIndex].options.length]=new Option(daArray[i][daIndex*2],daArray[i][(daIndex*2)+1]);
                  if(TCN_selValueGroup[daIndex]==TCN_comboGroup[daIndex].options[lastValue].value){
                        TCN_comboGroup[daIndex].options[lastValue].selected=true;
                        selectionMade=true;
                  }
            }
      }
      if(selectionMade==false) TCN_comboGroup[daIndex].options[0].selected=true;
}      
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.length){
                  TCN_tempArray[index].length=0;
                  for(i=0;i<TCN_comboGroup[index-1].options.length;i++){
                        if(TCN_comboGroup[index-1].options[i].selected==true){
                              for(j=0;j<TCN_tempArray[index-1].length;j++){
                                    if(TCN_comboGroup[index-1].options[i].value==TCN_tempArray[index-1][j][(index*2)-1]) TCN_tempArray[index][TCN_tempArray[index].length]=TCN_tempArray[index-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&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; 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.length;i++) x=findObj(n,d.layers[i].document);
  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_county_name']; ?>+#+<?php echo $row_rscounty_town['c_county_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($rscounty_town)); ?>
TCN_reload();

      </script>
    </p>
   
    <p>
      <label for="lbl_lat">Latitude</label>
      <input type="text" name="latitude" id="latitude" value="<?php echo htmlspecialchars($_POST['new_lat']);?>" />
    </p>
  <p>
      <label for="lbl_long">Longitude</label>
      <input type="text" name="longitude" id="longitude" value="<?php echo htmlspecialchars($_POST['new_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>&nbsp;</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>
0
 
dereksheahanAuthor Commented:
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('../Connections/reacha_new.php'); ?>
<?php
function GetSQLValueString($theValue, $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_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_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_username'], "text"),
                                 GetSQLValueString($_POST['txt_full_add'], "text"),
                                 GetSQLValueString($_POST['drop_travel'], "text"),
                                 GetSQLValueString($_POST['teacher_type'], "int"),
                       GetSQLValueString($_POST['txt_password'], "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_gender'], "text"),
                       GetSQLValueString($_POST['txt_availabilty'], "text"));

  mysql_select_db($database_reacha_new, $reacha_new);
  $Result1 = mysql_query($insertSQL, $reacha_new) or die(mysql_error());
 
  $insertGoTo = "../Registration/reg3per.php";
  if (isset($_SERVER['QUERY_STRING'])) {
    $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
    $insertGoTo .= $_SERVER['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $insertGoTo));
}


 //require_once('../Connections/reacha_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_rscounty_town, $reacha_new) or die(mysql_error());
$row_rscounty_town = mysql_fetch_assoc($rscounty_town);
$totalRows_rscounty_town = mysql_num_rows($rscounty_town);
?>


Thanks for your time,
D
0
 
ThGCommented:
can't you simply check out the html source code before hitting submit button?

the code you posted looks right at first skimming
0
 
dereksheahanAuthor Commented:
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('../Connections/reacha_new.php'); ?>
<?php
ini_set('error_reporting', E_ALL);
ini_set('display_errors', 'On');
ini_set('display_startup_errors', '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_rsSubjects, $reacha_new) or die(mysql_error());
$row_rsSubjects = mysql_fetch_assoc($rsSubjects);
$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(activities.length,0,new Array());
     activities[activities.length - 1][0] = value[0];
     activities[activities.length - 1][1] = value[1];
     }
}
document.form1.activityId.value = ''
document.getElementById('Chosen').innerHTML = ''

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('Chosen').innerHTML = document.getElementById('Chosen').innerHTML + div;
      }
   else{
      document.form1.activityId.value = activities[x][0];
      document.getElementById('Chosen').innerHTML = div;
      }
   }

}
function removeActivity(id){
for(var x in activities){
    if(activities[x][0]==id){
       activities.splice(x,1);
       }
    }
addActivity();
}
function clearAll(){
activities.splice(0,activities.length);
document.getElementById('Chosen').innerHTML = '';
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(this)">
        <option selected="selected">Subjects</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.length;i++){
            TCN_arrayValues[i]=TCN_contents[i].split(separator);
            TCN_tempArray[0]=TCN_arrayValues;
      }
}
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.arguments;
      for(i=0;i<args.length;i++) TCN_comboGroup[i]=findObj(args[i]);
}
function TCN_setDefault(){
      for (i=TCN_selValueGroup.length-1;i>=0;i--){
            if(TCN_selValueGroup[i]!=""){
                  for(j=0;j<TCN_contents.length;j++){
                        if(TCN_arrayValues[j][(i*2)+1]==TCN_selValueGroup[i]){
                              for(k=i;k>=0;k--){
                                    if(TCN_selValueGroup[k]=="") TCN_selValueGroup[k]=TCN_arrayValues[j][(k*2)+1];
                              }
                        }
                  }
            }
      }
}
function TCN_loadMenu(daIndex){
      var selectionMade=false;
      daArray=TCN_tempArray[daIndex];
      TCN_comboGroup[daIndex].options.length=0;
      for(i=0;i<daArray.length;i++){
            existe=false;
            for(j=0;j<TCN_comboGroup[daIndex].options.length;j++){
                  if(daArray[i][(daIndex*2)+1]==TCN_comboGroup[daIndex].options[j].value) existe=true;
            }
            if(existe==false){
                  lastValue=TCN_comboGroup[daIndex].options.length;
                  TCN_comboGroup[daIndex].options[TCN_comboGroup[daIndex].options.length]=new Option(daArray[i][daIndex*2],daArray[i][(daIndex*2)+1]);
                  if(TCN_selValueGroup[daIndex]==TCN_comboGroup[daIndex].options[lastValue].value){
                        TCN_comboGroup[daIndex].options[lastValue].selected=true;
                        selectionMade=true;
                  }
            }
      }
      if(selectionMade==false) TCN_comboGroup[daIndex].options[0].selected=true;
}      
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.length){
                  TCN_tempArray[index].length=0;
                  for(i=0;i<TCN_comboGroup[index-1].options.length;i++){
                        if(TCN_comboGroup[index-1].options[i].selected==true){
                              for(j=0;j<TCN_tempArray[index-1].length;j++){
                                    if(TCN_comboGroup[index-1].options[i].value==TCN_tempArray[index-1][j][(index*2)-1]) TCN_tempArray[index][TCN_tempArray[index].length]=TCN_tempArray[index-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&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; 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.length;i++) x=findObj(n,d.layers[i].document);
  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_type']; ?>+#+<?php echo $row_rsSubjects['mc_cat_id']; ?>+#+<?php echo $row_rsSubjects['sc_sub_cat_name']; ?>+#+<?php echo $row_rsSubjects['sc_sub_cat_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($rsSubjects)); ?>
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</label>
      <input type="submit" name="Submit" value="Submit" id="Submit" />
    </p>
      <?php echo $_POST['member_id'] ?>
  </form>
</div>
<div id="Chosen">
  <p>&nbsp;  </p>
  <p>&nbsp;</p>
  <p>&nbsp;</p>
  <p>&nbsp;</p>
  <p>&nbsp;</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($rsSubjects);
?>
0
 
ThGCommented:
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
0
 
dereksheahanAuthor Commented:
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.php";
  if (isset($_SERVER['QUERY_STRING'])) {
    $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
    $insertGoTo .= $_SERVER['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $insertGoTo));
}

could this be nulling the variable?
Thanks,
D
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
>>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 )
0
 
dereksheahanAuthor Commented:
Hi angel,
How would I pass this value to $_SESSION?
Thanks for your help,
D
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:

 $insertGoTo = "../Registration/reg3per.php";
  if (isset($_SERVER['QUERY_STRING'])) {
    $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
    $insertGoTo .= $_SERVER['QUERY_STRING'];
   }
  $_SESSION['member_id'] = @$_POST['member_id'];
  header(sprintf("Location: %s", $insertGoTo));
}



and in the next page:

<?php echo $_SESSION['member_id']; ?>



0
 
dereksheahanAuthor Commented:
Hi angel,
Still gives the error:
Notice: Undefined variable: _SESSION in C:\xxx\reg3per.php on line 247

Thanks again,
D
0
 
mach-Commented:
remember to call session_start() at the very beginning of the page.
0
 
dereksheahanAuthor Commented:
Great, thanks mach-. I have to put the session_start() on both pages?
Thanks,
D
0
 
mach-Commented:
Yes, you must call session_start() on every page that you use a session variable.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 8
  • 4
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now