Jump to content

Session Variable probs??


BoarderLine

Recommended Posts

PHP 5.2

 

Pulling teeth over this one as just can't get it work although should be very simple. 

 

I am trying to pass a form input value from one page to the next using a session variable- I have the following code on the first page which contains the from:

 

session_start();
if (isset($HTTP_POST_VARS['Address'])) {$Address = $HTTP_POST_VARS['Address'];
session_register("Address");
}

 

And am simply trying to echo the variable on the second with:

 

<p><?php echo $_SESSION['Address']; ?></p>

 

The page runs without error although the 'Address' value from the form on page one is not being passed (or is empty).

 

Any ideas and on what could be going wrong here? Thanks in advance

Link to comment
Share on other sites

Heres my form:

 

<form id="formReg" name="formReg" method="post">
						<div id="formregion">

								<div id="Club_Name">
										<div class="formLabel">Club Name:</div>
						<input name="Club_Name" type="text" class="input" id="Club_Name" value="" />
						<span class="textfieldRequiredMsg">Please enter your Clubs Name.</span>
							<img src="images/ok.gif" title="Valid" alt="Valid" class="validMsg" border="0"/></div>

							<div id="City">
							<div class="formLabel">City:</div>
						<select name="city1" id="city1">
								<option value="" selected><?php echo $_SESSION['kt_City']; ?></option>
								<?php
do {  
?>
								<option value="<?php echo $row_Cities['City']?>"><?php echo $row_Cities['City']?></option>
								<?php
} while ($row_Cities = mysql_fetch_assoc($Cities));
  $rows = mysql_num_rows($Cities);
  if($rows > 0) {
      mysql_data_seek($rsCities, 0);
  $row_Cities = mysql_fetch_assoc($Cities);
  }
?>
								</select>
							<img src="images/ok.gif" title="Valid" alt="Valid" class="validMsg" border="0"/>
							<span class="selectRequiredMsg">Please select a city.</span>		 </div>
				<div id="Address">
										<div class="formLabel">Club Address:</div>
						<input name="Address" type="text" class="input" id="Address" value="" />
						<span class="textfieldRequiredMsg">Please enter your Clubs Address</span>
							<img src="images/ok.gif" title="Valid" alt="Valid" class="validMsg" border="0"/></div>


				<div id="Cat">
							<div class="formLabel">Select a category for your club listing:</div>
				<select name="select" id="select">
						<option value="" <?php if (!(strcmp("", $row_Recordset1['EventCat']))) {echo "selected=\"selected\"";} ?>>Please Select...</option>
						<?php
do {  
?><option value="<?php echo $row_Recordset1['CatID']?>"<?php if (!(strcmp($row_Recordset1['CatID'], $row_Recordset1['EventCat']))) {echo "selected=\"selected\"";} ?>><?php echo $row_Recordset1['EventCat']?></option>
						<?php
} while ($row_Recordset1 = mysql_fetch_assoc($Recordset1));
  $rows = mysql_num_rows($Recordset1);
  if($rows > 0) {
      mysql_data_seek($Recordset1, 0);
  $row_Recordset1 = mysql_fetch_assoc($Recordset1);
  }
?>
		</select>
		<select name="select1" id="select1" wdg:subtype="DependentDropdown" wdg:type="widget" wdg:recordset="Recordset2" wdg:displayfield="subcat_name" wdg:valuefield="SubCatID" wdg:fkey="CatID" wdg:triggerobject="select" wdg:selected="<?php echo $row_Recordset2['subcat_name']; ?>">
		</select>

	</div>
			<div id="Description">
	 	<div class="formLabel">Enter your Club Description:</div>
				<textarea name="Description" id="Description" cols="45" rows="5"></textarea>				
				<img src="images/ok.gif" title="Valid" alt="Valid" class="validMsg" border="0"/>
				<span class="textareaRequiredMsg">Please enter a description.</span>
				<span class="textareaMinCharsMsg">Please enter at least 100 characters.</span>
			<span id="Countvalidta1"> </span> / 2000		</div>
		<div id="ContactNum">
										<div class="formLabel">Club Contact Phone  Number:</div>
									<input name="ContactNum" type="text" class="input" id="ContactNum" value="<?php echo $_SESSION['kt_MobileNum']; ?>" />
										<img src="images/ok.gif" title="Valid" alt="Valid" class="validMsg" border="0"/>
									<span class="textfieldRequiredMsg">Please enter a contact number</span>
							<span class="textfieldInvalidFormatMsg">Number format required ###-#######</span> 													                         </div>		
							<div id="Email">
			<div class="formLabelEmail">Club Contact Email Address: <em>(This will not be displayed to the public)</em></div>
							<input name="Email1" type="text" class="input" id="Email1" value="<?php echo $_SESSION['kt_login_user']; ?>" />
			<span class="textfieldRequiredMsg">Please enter a Valid Email Address.</span> <span class="textfieldInvalidFormatMsg">Invalid format</span></div>
							<img src="images/ok.gif" title="Valid" alt="Valid" class="validMsg" border="0"/>  
	</div>

						<input name="KT_Insert1"  id="KT_Insert1" type="submit" class="submit" value="Next" />	

					<?php
echo $tNGs->getErrorMsg();
?>

					<input type="hidden" name="ClubID" id="ClubID" />
  </form>

Link to comment
Share on other sites

Thanks Ted, The first php code is on the page with the form, the second php code is on the page the user is redirected to after form submission.  I am trying to get the value entered in the form field "Address" echo'd on the second page and figured this would be best set as a session variable with the session value set as the form field "Address" value.  What you think?

Link to comment
Share on other sites

You're using outdated session and post functions/globals.  Try this:

page 1:

session_start();
if (isset($_POST['Address'])) $_SESSION['Address'] = $_POST['Address'];
}

 

page 2:

session_start();
if(isset($_SESSION['Address'])) echo $_SESSION['Address'];

Link to comment
Share on other sites

A missing action="..." parameter will cause the form to submit to the same page. If that is the correct operation, then that piece of the puzzle is not important.

 

Just posting fragments of code does not help someone to directly help you. Please just post all your code so that someone could directly tell you of problems in it that would prevent sessions from working.

 

Are you developing and debugging this on a system with error_reporting set to E_ALL and display_errors set to ON so that problems with the session and post variables are output to the browser?

Link to comment
Share on other sites

Thanks.

 

php.ini settings

 

error_reporting  =  E_ALL & ~E_NOTICE

display_errors = On

 

All Code from first page:

 

<?php session_start(); ?>
<?php require_once('Connections/Stuff2do.php'); ?>
<?php
//MX Widgets3 include
require_once('includes/wdg/WDG.php');

// Load the common classes
require_once('includes/common/KT_common.php');

// Load the tNG classes
require_once('includes/tng/tNG.inc.php');

// Make a transaction dispatcher instance
$tNGs = new tNG_dispatcher("");

// Make unified connection variable
$conn_Stuff2do = new KT_connection($Stuff2do, $database_Stuff2do);

if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($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;
}
}

mysql_select_db($database_Stuff2do, $Stuff2do);
$query_Cities = "SELECT City FROM cities ORDER BY City ASC";
$Cities = mysql_query($query_Cities, $Stuff2do) or die(mysql_error());
$row_Cities = mysql_fetch_assoc($Cities);
$totalRows_Cities = mysql_num_rows($Cities);

mysql_select_db($database_Stuff2do, $Stuff2do);
$query_Recordset1 = "SELECT CatID, EventCat FROM event_categories ORDER BY EventCat ASC";
$Recordset1 = mysql_query($query_Recordset1, $Stuff2do) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);

mysql_select_db($database_Stuff2do, $Stuff2do);
$query_Recordset2 = "SELECT * FROM event_subcats ORDER BY subcat_name ASC";
$Recordset2 = mysql_query($query_Recordset2, $Stuff2do) or die(mysql_error());
$row_Recordset2 = mysql_fetch_assoc($Recordset2);
$totalRows_Recordset2 = mysql_num_rows($Recordset2);

// Make an insert transaction instance
$ins_clubs = new tNG_insert($conn_Stuff2do);
$tNGs->addTransaction($ins_clubs);
// Register triggers
$ins_clubs->registerTrigger("STARTER", "Trigger_Default_Starter", 1, "POST", "KT_Insert1");
$ins_clubs->registerTrigger("END", "Trigger_Default_Redirect", 99, "Reg_Club_Pics.php");
// Add columns

$ins_clubs->setTable("clubs");
$ins_clubs->addColumn("ListingCat", "STRING_TYPE", "POST", "select");
$ins_clubs->addColumn("UserID", "NUMERIC_TYPE", "SESSION", "kt_login_id", "{SESSION.kt_login_id}");
$ins_clubs->addColumn("ListSubCat", "STRING_TYPE", "POST", "select1");
$ins_clubs->addColumn("ClubName", "STRING_TYPE", "POST", "Club_Name");
$ins_clubs->addColumn("Discription", "STRING_TYPE", "POST", "Description");
$ins_clubs->addColumn("City", "STRING_TYPE", "POST", "city1");
$ins_clubs->addColumn("Address", "STRING_TYPE", "POST", "Address");
$ins_clubs->addColumn("ClubContact", "STRING_TYPE", "POST", "Email1");
$ins_clubs->setPrimaryKey("ClubID", "NUMERIC_TYPE", "POST", "ClubID");

// Execute all the registered transactions
$tNGs->executeTransactions();

// Get the transaction recordset
$rsclubs = $tNGs->getRecordset("clubs");
$row_rsclubs = mysql_fetch_assoc($rsclubs);
$totalRows_rsclubs = mysql_num_rows($rsclubs);


if (isset($_POST['KT_Insert1'])) {
$add = $_POST['Address'];
$_SESSION['Address'] = $add;}
?>

<!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" xmlns:wdg="http://ns.adobe.com/addt">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Stuff2do - Club Registration</title>

<link href="css/screen.css" rel="stylesheet" type="text/css" media="all" />
<link href="SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css" />
<link href="SpryAssets/SpryValidationSelect.css" rel="stylesheet" type="text/css" />
<link href="SpryAssets/SpryValidationTextarea.css" rel="stylesheet" type="text/css" />
<link href="SpryAssets/SpryValidationCheckbox.css" rel="stylesheet" type="text/css" />
<link href="SpryAssets/validation.css" rel="stylesheet" type="text/css" media="all" />

<script type="text/javascript" src="SpryAssets/SpryValidationTextField.js"></script>
<script type="text/javascript" src="SpryAssets/SpryValidationSelect.js"></script>
<script type="text/javascript" src="SpryAssets/SpryValidationTextarea.js"></script>
<script type="text/javascript" src="SpryAssets/SpryValidationCheckbox.js"></script>
<script src="includes/skins/style.js" type="text/javascript"></script>
<script src="includes/common/js/base.js" type="text/javascript"></script>
<script src="includes/common/js/utility.js" type="text/javascript"></script>
<script type="text/javascript" src="includes/common/js/sigslot_core.js"></script>
<script type="text/javascript" src="includes/wdg/classes/MXWidgets.js"></script>
<script type="text/javascript" src="includes/wdg/classes/MXWidgets.js.php"></script>
<script type="text/javascript" src="includes/wdg/classes/JSRecordset.js"></script>
<script type="text/javascript" src="includes/wdg/classes/DependentDropdown.js"></script>
<?php
//begin JSRecordset
$jsObject_Recordset2 = new WDG_JsRecordset("Recordset2");
echo $jsObject_Recordset2->getOutput();
//end JSRecordset
?>
<link href="includes/skins/mxkollection3.css" rel="stylesheet" type="text/css" media="all" />

</head>

<body class="oneColFixCtr">

<div id="container">
  <div id="mainContent">
  <noscript><h1>This page requires JavaScript. Please enable JavaScript in your browser and reload this page.</h1></noscript>
  <div id="CentralColumn">
  <form id="formReg" name="formReg" method="post">
						<div id="formregion">

								<div id="Club_Name">
										<div class="formLabel">Club Name:</div>
						<input name="Club_Name" type="text" class="input" id="Club_Name" value="" />
						<span class="textfieldRequiredMsg">Please enter your Clubs Name.</span>
							<img src="images/ok.gif" title="Valid" alt="Valid" class="validMsg" border="0"/></div>

							<div id="City">
							<div class="formLabel">City:</div>
						<select name="city1" id="city1">
								<option value="" selected><?php echo $_SESSION['kt_City']; ?></option>
								<?php
do {  
?>
								<option value="<?php echo $row_Cities['City']?>"><?php echo $row_Cities['City']?></option>
								<?php
} while ($row_Cities = mysql_fetch_assoc($Cities));
  $rows = mysql_num_rows($Cities);
  if($rows > 0) {
      mysql_data_seek($rsCities, 0);
  $row_Cities = mysql_fetch_assoc($Cities);
  }
?>
								</select>
							<img src="images/ok.gif" title="Valid" alt="Valid" class="validMsg" border="0"/>
							<span class="selectRequiredMsg">Please select a city.</span>		 </div>
				<div id="Address">
										<div class="formLabel">Club Address:</div>
						<input name="Address" type="text" class="input" id="Address" value="" />
						<span class="textfieldRequiredMsg">Please enter your Clubs Address</span>
							<img src="images/ok.gif" title="Valid" alt="Valid" class="validMsg" border="0"/></div>


				<div id="Cat">
							<div class="formLabel">Select a category for your club listing:</div>
				<select name="select" id="select">
						<option value="" <?php if (!(strcmp("", $row_Recordset1['EventCat']))) {echo "selected=\"selected\"";} ?>>Please Select...</option>
						<?php
do {  
?><option value="<?php echo $row_Recordset1['CatID']?>"<?php if (!(strcmp($row_Recordset1['CatID'], $row_Recordset1['EventCat']))) {echo "selected=\"selected\"";} ?>><?php echo $row_Recordset1['EventCat']?></option>
						<?php
} while ($row_Recordset1 = mysql_fetch_assoc($Recordset1));
  $rows = mysql_num_rows($Recordset1);
  if($rows > 0) {
      mysql_data_seek($Recordset1, 0);
  $row_Recordset1 = mysql_fetch_assoc($Recordset1);
  }
?>
		</select>
		<select name="select1" id="select1" wdg:subtype="DependentDropdown" wdg:type="widget" wdg:recordset="Recordset2" wdg:displayfield="subcat_name" wdg:valuefield="SubCatID" wdg:fkey="CatID" wdg:triggerobject="select" wdg:selected="<?php echo $row_Recordset2['subcat_name']; ?>">
		</select>

	</div>
			<div id="Description">
	 	<div class="formLabel">Enter your Club Description:</div>
				<textarea name="Description" id="Description" cols="45" rows="5"></textarea>				
				<img src="images/ok.gif" title="Valid" alt="Valid" class="validMsg" border="0"/>
				<span class="textareaRequiredMsg">Please enter a description.</span>
				<span class="textareaMinCharsMsg">Please enter at least 100 characters.</span>
			<span id="Countvalidta1"> </span> / 2000		</div>
		<div id="ContactNum">
										<div class="formLabel">Club Contact Phone  Number:</div>
									<input name="ContactNum" type="text" class="input" id="ContactNum" value="<?php echo $_SESSION['kt_MobileNum']; ?>" />
										<img src="images/ok.gif" title="Valid" alt="Valid" class="validMsg" border="0"/>
									<span class="textfieldRequiredMsg">Please enter a contact number</span>
							<span class="textfieldInvalidFormatMsg">Number format required ###-#######</span> 													                         </div>		
							<div id="Email">
			<div class="formLabelEmail">Club Contact Email Address: <em>(This will not be displayed to the public)</em></div>
							<input name="Email1" type="text" class="input" id="Email1" value="<?php echo $_SESSION['kt_login_user']; ?>" />
			<span class="textfieldRequiredMsg">Please enter a Valid Email Address.</span> <span class="textfieldInvalidFormatMsg">Invalid format</span></div>
							<img src="images/ok.gif" title="Valid" alt="Valid" class="validMsg" border="0"/>  
	</div>

						<input name="KT_Insert1"  id="KT_Insert1" type="submit" class="submit" value="Next" />	

					<?php
echo $tNGs->getErrorMsg();
?>

					<input type="hidden" name="ClubID" id="ClubID" />
  </form>
  

  </div>
  
  
  
    <!-- end #mainContent --></div>
<!-- end #container --></div>
<script type="text/javascript">

var Description = new Spry.Widget.ValidationTextarea("Description", {useCharacterMasking:true, minChars:100, maxChars:2000, counterType:"chars_count", counterId:"Countvalidta1", validateOn:["change"]});
var Club_Name = new Spry.Widget.ValidationTextField("Club_Name", "none", {useCharacterMasking:true, validateOn:["change"]});
var City = new Spry.Widget.ValidationSelect("City", {validateOn:["change"]});
var Address = new Spry.Widget.ValidationTextField("Address", "none", {useCharacterMasking:true, validateOn:["change"]});
var Email = new Spry.Widget.ValidationTextField("Email", "email", {useCharacterMasking:true, validateOn:["blur"]});
var ContactNum = new Spry.Widget.ValidationTextField("ContactNum", "none", {useCharacterMasking:true, format:"\d\d\d-\d\d\d-\d\d\d\d", hint:"###-#######", validateOn:["change"]});
</script>
</body>
</html>
<?php
mysql_free_result($Cities);

mysql_free_result($Recordset1);

mysql_free_result($Recordset2);

?>

 

 

All Code from second page:

 

<?php session_start(); ?>
<?php require_once('Connections/Stuff2do.php'); ?>
<?php
// Load the common classes
require_once('includes/common/KT_common.php');

// Load the tNG classes
require_once('includes/tng/tNG.inc.php');

// Make a transaction dispatcher instance
$tNGs = new tNG_dispatcher("");

// Make unified connection variable
$conn_Stuff2do = new KT_connection($Stuff2do, $database_Stuff2do);

// Start trigger
$formValidation = new tNG_FormValidation();
$tNGs->prepareValidation($formValidation);
// End trigger

//start Trigger_ImageUpload trigger
//remove this line if you want to edit the code by hand 
function Trigger_ImageUpload(&$tNG) {
  $uploadObj = new tNG_ImageUpload($tNG);
  $uploadObj->setFormFieldName("Filedata");
  $uploadObj->setDbFieldName("ImageFile");
  $uploadObj->setFolder("images/ClubListing_Pics/");
  $uploadObj->setResize("true", 200, 200);
  $uploadObj->setMaxSize(4000);
  $uploadObj->setAllowedExtensions("gif, jpg, jpe, jpeg, png");
  $uploadObj->setRename("auto");
  return $uploadObj->Execute();
}
//end Trigger_ImageUpload trigger

//start Trigger_Redirect trigger
//remove this line if you want to edit the code by hand
function Trigger_Redirect(&$tNG) {
  $redObj = new tNG_Redirect($tNG);
  $redObj->setURL(KT_getFullUri());
  $redObj->setKeepURLParams(false);
  return $redObj->Execute();
}
//end Trigger_Redirect trigger

// Make an insert transaction instance
$ins_clublistingpics = new tNG_insert($conn_Stuff2do);
$tNGs->addTransaction($ins_clublistingpics);
// Register triggers
$ins_clublistingpics->registerTrigger("STARTER", "Trigger_Default_Starter", 1, "POST", "KT_Insert1");
$ins_clublistingpics->registerTrigger("BEFORE", "Trigger_Default_FormValidation", 10, $formValidation);
$ins_clublistingpics->registerTrigger("STARTER", "Trigger_Default_Starter", 1, "FILES", "Filedata");
$ins_clublistingpics->registerConditionalTrigger("{GET.isFlash} != 1", "END", "Trigger_Redirect", 90);
$ins_clublistingpics->registerTrigger("AFTER", "Trigger_ImageUpload", 97);
$ins_clublistingpics->registerConditionalTrigger("{GET.isFlash} == 1", "ERROR", "Trigger_Default_MUploadError", 10);
// Add columns
$ins_clublistingpics->setTable("clublistingpics");
$ins_clublistingpics->addColumn("UploadDate", "DATE_TYPE", "VALUE", "{now}");
$ins_clublistingpics->addColumn("ClubID", "NUMERIC_TYPE", "SESSION", "ClubID", "[sESSION.ClubID]");
$ins_clublistingpics->addColumn("DefaultPic", "STRING_TYPE", "VALUE", "Yes");
$ins_clublistingpics->addColumn("ImageFile", "FILE_TYPE", "FILES", "Filedata");
$ins_clublistingpics->setPrimaryKey("PicsID", "NUMERIC_TYPE");

// Execute all the registered transactions
$tNGs->executeTransactions();

// Get the transaction recordset
$rsclublistingpics = $tNGs->getRecordset("clublistingpics");
$row_rsclublistingpics = mysql_fetch_assoc($rsclublistingpics);
$totalRows_rsclublistingpics = mysql_num_rows($rsclublistingpics);

// Multiple Upload Helper Object
$muploadHelper = new tNG_MuploadHelper("", 32);
$muploadHelper->setMaxSize(4000);
$muploadHelper->setMaxNumber(0);
$muploadHelper->setExistentNumber(0);
$muploadHelper->setAllowedExtensions("gif, jpg, jpe, jpeg, png");
?>
<!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=utf-8" />
<title>Stuff2do - Club Registration</title>
<link href="css/screen.css" rel="stylesheet" type="text/css" />
<link href="includes/skins/mxkollection3.css" rel="stylesheet" type="text/css" media="all" />
<script src="includes/common/js/base.js" type="text/javascript"></script>
<script src="includes/common/js/utility.js" type="text/javascript"></script>
<script src="includes/skins/style.js" type="text/javascript"></script>
<?php echo $tNGs->displayValidationRules();?><?php echo $muploadHelper->getScripts(); ?>


</head>

<body class="oneColFixCtr">

<div id="container">
  <div id="mainContent">

    	<div id="CentralColumn">
<h2>UPLOAD CLUB IMAGES </h2> 
<p><?php echo $_SESSION['Address']; ?></p>
<div id="PrimaryPic">
		<?php
echo $tNGs->getErrorMsg();
?>
		<?php
// Multiple Upload Helper
echo $tNGs->getSavedErrorMsg();
echo $muploadHelper->Execute();
?>
</div>	
<div id="Pic1"></div>
</div>
<!-- end #mainContent --></div>
<!-- end #container --></div>
</body>
</html>

Link to comment
Share on other sites

Use -

 

error_reporting  =  E_ALL

 

because turning off NOTICE errors hides problems in your code that would tell you why it is not working. Stop and start your web server to get any changes made to php.ini to take effect and then confirm what those two settings actually are using a phpinfo() statement.

Link to comment
Share on other sites

Hey thanks PFMaBiSmAd, I finally got a hold on my over enthusiastic nature to run ahead of myself and to go back over what your telling me here.  Very good advise thanks.  I have managed to get the php report using a phpinfo() statement and it's good to be pointed in the right direction not only with this but everything from here out.  Regards.  ;)

Link to comment
Share on other sites

Ok so I changed the wrong php.ini file before and have now changed the correct one in the Apache folder.  I now have the setting error_reporting = 6143 showing in the phpinfo() report, and am receiving the error, which is:

 

Notice: Undefined index: Address in C:\xampp\htdocs\Reg_Club_Pics.php on line 102

 

Line 102 of Reg_Club_Pics.php

<p><?php echo $_SESSION['Address']; ?></p>

 

But why when it was set on the previous page???

 

 

Link to comment
Share on other sites

You changed the form action so that it submits the form data to the second page. So, the code on the first page that sets the session variable is no longer being executed (assuming that when the form used to submit to the first page that the code was actually being executed.)

 

In the code on the first page, exactly at what point in that code does it redirect to the second page. What does the following line cause to happen and when -

 

$ins_clubs->registerTrigger("END", "Trigger_Default_Redirect", 99, "Reg_Club_Pics.php");

Link to comment
Share on other sites

Just an update on the form action value, I have removed this so its now as it was previously (still no joy).  The line

$ins_clubs->registerTrigger("END", "Trigger_Default_Redirect", 99, "Reg_Club_Pics.php");

Is part of the Form processing transaction, beginning with the Insert into DB of the Form values and  this one being the END trigger which redirects the user once all page transactions have been processed. With it's priority set at 99 it will be the final transaction on the page that is processed.  (well thats how i see it anyway, but im very new to this).

Link to comment
Share on other sites

Ok I have it working now without the error message Notice: Undefined index: Address in C:\xampp\htdocs\Reg_Club_Pics.php on line 102, however the variable is still not being displayed.  So I assume if there is no error it is getting it's value ok but it's empty??? Here are my updated pages.

 

Page 1

<?php if (!isset($_SESSION)) session_start(); ?>
<?php require_once('Connections/Stuff2do.php'); ?>
<?php
//MX Widgets3 include
require_once('includes/wdg/WDG.php');

// Load the common classes
require_once('includes/common/KT_common.php');

// Load the tNG classes
require_once('includes/tng/tNG.inc.php');

// Make a transaction dispatcher instance
$tNGs = new tNG_dispatcher("");

// Make unified connection variable
$conn_Stuff2do = new KT_connection($Stuff2do, $database_Stuff2do);

if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($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;
}
}

mysql_select_db($database_Stuff2do, $Stuff2do);
$query_Cities = "SELECT City FROM cities ORDER BY City ASC";
$Cities = mysql_query($query_Cities, $Stuff2do) or die(mysql_error());
$row_Cities = mysql_fetch_assoc($Cities);
$totalRows_Cities = mysql_num_rows($Cities);

mysql_select_db($database_Stuff2do, $Stuff2do);
$query_Recordset1 = "SELECT CatID, EventCat FROM event_categories ORDER BY EventCat ASC";
$Recordset1 = mysql_query($query_Recordset1, $Stuff2do) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);

mysql_select_db($database_Stuff2do, $Stuff2do);
$query_Recordset2 = "SELECT * FROM event_subcats ORDER BY subcat_name ASC";
$Recordset2 = mysql_query($query_Recordset2, $Stuff2do) or die(mysql_error());
$row_Recordset2 = mysql_fetch_assoc($Recordset2);
$totalRows_Recordset2 = mysql_num_rows($Recordset2);

// Make an insert transaction instance
$ins_clubs = new tNG_insert($conn_Stuff2do);
$tNGs->addTransaction($ins_clubs);
// Register triggers
$ins_clubs->registerTrigger("STARTER", "Trigger_Default_Starter", 1, "POST", "KT_Insert1");
$ins_clubs->registerTrigger("END", "Trigger_Default_Redirect", 99, "Reg_Attract_Pics.php");
// Add columns
$ins_clubs->setTable("clubs");
$ins_clubs->addColumn("ListingCat", "STRING_TYPE", "POST", "select");
$ins_clubs->addColumn("ListSubCat", "STRING_TYPE", "POST", "select1");
$ins_clubs->addColumn("ClubName", "STRING_TYPE", "POST", "Club_Name");
$ins_clubs->addColumn("ClubContact", "STRING_TYPE", "POST", "Email1", "{SESSION.kt_login_user}");
$ins_clubs->addColumn("UserID", "NUMERIC_TYPE", "SESSION", "kt_login_id", "{SESSION.kt_login_id}");
$ins_clubs->addColumn("Discription", "STRING_TYPE", "POST", "Description");
$ins_clubs->addColumn("City", "STRING_TYPE", "POST", "city1", "{SESSION.kt_City}");
$ins_clubs->addColumn("Address", "STRING_TYPE", "POST", "Address");
$ins_clubs->setPrimaryKey("ClubID", "NUMERIC_TYPE");

// Execute all the registered transactions
$tNGs->executeTransactions();

// Get the transaction recordset
$rsclubs = $tNGs->getRecordset("clubs");
$row_rsclubs = mysql_fetch_assoc($rsclubs);
$totalRows_rsclubs = mysql_num_rows($rsclubs);

if (isset($_POST['KT_Insert1'])) {
$add = $_POST['Address'];
$_SESSION['Address'] = $add;}
?>


<!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" xmlns:wdg="http://ns.adobe.com/addt">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Stuff2do - Club Registration</title>

<link href="css/screen.css" rel="stylesheet" type="text/css" media="all" />
<link href="SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css" />
<link href="SpryAssets/SpryValidationSelect.css" rel="stylesheet" type="text/css" />
<link href="SpryAssets/SpryValidationTextarea.css" rel="stylesheet" type="text/css" />
<link href="SpryAssets/SpryValidationCheckbox.css" rel="stylesheet" type="text/css" />
<link href="SpryAssets/validation.css" rel="stylesheet" type="text/css" media="all" />

<script type="text/javascript" src="SpryAssets/SpryValidationTextField.js"></script>
<script type="text/javascript" src="SpryAssets/SpryValidationSelect.js"></script>
<script type="text/javascript" src="SpryAssets/SpryValidationTextarea.js"></script>
<script type="text/javascript" src="SpryAssets/SpryValidationCheckbox.js"></script>
<script src="includes/skins/style.js" type="text/javascript"></script>
<script src="includes/common/js/base.js" type="text/javascript"></script>
<script src="includes/common/js/utility.js" type="text/javascript"></script>
<script type="text/javascript" src="includes/common/js/sigslot_core.js"></script>
<script type="text/javascript" src="includes/wdg/classes/MXWidgets.js"></script>
<script type="text/javascript" src="includes/wdg/classes/MXWidgets.js.php"></script>
<script type="text/javascript" src="includes/wdg/classes/JSRecordset.js"></script>
<script type="text/javascript" src="includes/wdg/classes/DependentDropdown.js"></script>
<?php
//begin JSRecordset
$jsObject_Recordset2 = new WDG_JsRecordset("Recordset2");
echo $jsObject_Recordset2->getOutput();
//end JSRecordset
?>
<link href="includes/skins/mxkollection3.css" rel="stylesheet" type="text/css" media="all" />

</head>

<body class="oneColFixCtr">

<div id="container">
  <div id="mainContent">
  <noscript><h1>This page requires JavaScript. Please enable JavaScript in your browser and reload this page.</h1></noscript>
  <div id="CentralColumn">
  <form id="formReg" name="formReg" method="post">
						<div id="formregion">

								<div id="Club_Name">
										<div class="formLabel">Club Name:</div>
						<input name="Club_Name" type="text" class="input" id="Club_Name" value="" />
						<span class="textfieldRequiredMsg">Please enter your Clubs Name.</span>
							<img src="images/ok.gif" title="Valid" alt="Valid" class="validMsg" border="0"/></div>

							<div id="City">
							<div class="formLabel">City:</div>
						<select name="city1" id="city1">
								<option value="" selected><?php echo $_SESSION['kt_City']; ?></option>
								<?php
do {  
?>
								<option value="<?php echo $row_Cities['City']?>"><?php echo $row_Cities['City']?></option>
								<?php
} while ($row_Cities = mysql_fetch_assoc($Cities));
  $rows = mysql_num_rows($Cities);
  if($rows > 0) {
      mysql_data_seek($rsCities, 0);
  $row_Cities = mysql_fetch_assoc($Cities);
  }
?>
								</select>
							<img src="images/ok.gif" title="Valid" alt="Valid" class="validMsg" border="0"/>
							<span class="selectRequiredMsg">Please select a city.</span>		 </div>
				<div id="Address">
										<div class="formLabel">Club Address:</div>
						<input name="Address" type="text" class="input" id="Address" value="" />
						<span class="textfieldRequiredMsg">Please enter your Clubs Address</span>
							<img src="images/ok.gif" title="Valid" alt="Valid" class="validMsg" border="0"/></div>


				<div id="Cat">
							<div class="formLabel">Select a category for your club listing:</div>
				<select name="select" id="select">
						<option value="" <?php if (!(strcmp("", $row_Recordset1['EventCat']))) {echo "selected=\"selected\"";} ?>>Please Select...</option>
						<?php
do {  
?><option value="<?php echo $row_Recordset1['CatID']?>"<?php if (!(strcmp($row_Recordset1['CatID'], $row_Recordset1['EventCat']))) {echo "selected=\"selected\"";} ?>><?php echo $row_Recordset1['EventCat']?></option>
						<?php
} while ($row_Recordset1 = mysql_fetch_assoc($Recordset1));
  $rows = mysql_num_rows($Recordset1);
  if($rows > 0) {
      mysql_data_seek($Recordset1, 0);
  $row_Recordset1 = mysql_fetch_assoc($Recordset1);
  }
?>
		</select>
		<select name="select1" id="select1" wdg:subtype="DependentDropdown" wdg:type="widget" wdg:recordset="Recordset2" wdg:displayfield="subcat_name" wdg:valuefield="SubCatID" wdg:fkey="CatID" wdg:triggerobject="select" wdg:selected="<?php echo $row_Recordset2['subcat_name']; ?>">
		</select>

	</div>
			<div id="Description">
	 	<div class="formLabel">Enter your Club Description:</div>
				<textarea name="Description" id="Description" cols="45" rows="5"></textarea>				
				<img src="images/ok.gif" title="Valid" alt="Valid" class="validMsg" border="0"/>
				<span class="textareaRequiredMsg">Please enter a description.</span>
				<span class="textareaMinCharsMsg">Please enter at least 100 characters.</span>
			<span id="Countvalidta1"> </span> / 2000		</div>
		<div id="ContactNum">
										<div class="formLabel">Club Contact Phone  Number:</div>
									<input name="ContactNum" type="text" class="input" id="ContactNum" value="<?php echo $_SESSION['kt_MobileNum']; ?>" />
										<img src="images/ok.gif" title="Valid" alt="Valid" class="validMsg" border="0"/>
									<span class="textfieldRequiredMsg">Please enter a contact number</span>
							<span class="textfieldInvalidFormatMsg">Number format required ###-#######</span> 													                         </div>		
							<div id="Email">
			<div class="formLabelEmail">Club Contact Email Address: <em>(This will not be displayed to the public)</em></div>
							<input name="Email1" type="text" class="input" id="Email1" value="<?php echo $_SESSION['kt_login_user']; ?>" />
			<span class="textfieldRequiredMsg">Please enter a Valid Email Address.</span> <span class="textfieldInvalidFormatMsg">Invalid format</span></div>
							<img src="images/ok.gif" title="Valid" alt="Valid" class="validMsg" border="0"/>  
	</div>

						<input name="KT_Insert1"  id="KT_Insert1" type="submit" class="submit" value="Next" />	

					<?php
echo $tNGs->getErrorMsg();
?>

					<input type="hidden" name="ClubID" id="ClubID" />
  </form>
  

  </div>
  
  
  
    <!-- end #mainContent --></div>
<!-- end #container --></div>
<script type="text/javascript">

var Description = new Spry.Widget.ValidationTextarea("Description", {useCharacterMasking:true, minChars:100, maxChars:2000, counterType:"chars_count", counterId:"Countvalidta1", validateOn:["change"]});
var Club_Name = new Spry.Widget.ValidationTextField("Club_Name", "none", {useCharacterMasking:true, validateOn:["change"]});
var City = new Spry.Widget.ValidationSelect("City", {validateOn:["change"]});
var Address = new Spry.Widget.ValidationTextField("Address", "none", {useCharacterMasking:true, validateOn:["change"]});
var Email = new Spry.Widget.ValidationTextField("Email", "email", {useCharacterMasking:true, validateOn:["blur"]});
var ContactNum = new Spry.Widget.ValidationTextField("ContactNum", "none", {useCharacterMasking:true, format:"\d\d\d-\d\d\d-\d\d\d\d", hint:"###-#######", validateOn:["change"]});
</script>
</body>
</html>
<?php
mysql_free_result($Cities);

mysql_free_result($Recordset1);

mysql_free_result($Recordset2);

?>

 

Page 2

 

<?php session_start(); ?>
<?php require_once('Connections/Stuff2do.php'); ?>
<?php
// Load the common classes
require_once('includes/common/KT_common.php');

// Load the tNG classes
require_once('includes/tng/tNG.inc.php');

// Make a transaction dispatcher instance
$tNGs = new tNG_dispatcher("");

// Make unified connection variable
$conn_Stuff2do = new KT_connection($Stuff2do, $database_Stuff2do);

// Start trigger
$formValidation = new tNG_FormValidation();
$tNGs->prepareValidation($formValidation);
// End trigger

//start Trigger_ImageUpload trigger
//remove this line if you want to edit the code by hand 
function Trigger_ImageUpload(&$tNG) {
  $uploadObj = new tNG_ImageUpload($tNG);
  $uploadObj->setFormFieldName("Filedata");
  $uploadObj->setDbFieldName("ImageFile");
  $uploadObj->setFolder("images/ClubListing_Pics/");
  $uploadObj->setResize("true", 200, 200);
  $uploadObj->setMaxSize(4000);
  $uploadObj->setAllowedExtensions("gif, jpg, jpe, jpeg, png");
  $uploadObj->setRename("auto");
  return $uploadObj->Execute();
}
//end Trigger_ImageUpload trigger

//start Trigger_Redirect trigger
//remove this line if you want to edit the code by hand
function Trigger_Redirect(&$tNG) {
  $redObj = new tNG_Redirect($tNG);
  $redObj->setURL(KT_getFullUri());
  $redObj->setKeepURLParams(false);
  return $redObj->Execute();
}
//end Trigger_Redirect trigger

// Make an insert transaction instance
$ins_clublistingpics = new tNG_insert($conn_Stuff2do);
$tNGs->addTransaction($ins_clublistingpics);
// Register triggers
$ins_clublistingpics->registerTrigger("STARTER", "Trigger_Default_Starter", 1, "POST", "KT_Insert1");
$ins_clublistingpics->registerTrigger("BEFORE", "Trigger_Default_FormValidation", 10, $formValidation);
$ins_clublistingpics->registerTrigger("STARTER", "Trigger_Default_Starter", 1, "FILES", "Filedata");
$ins_clublistingpics->registerConditionalTrigger("{GET.isFlash} != 1", "END", "Trigger_Redirect", 90);
$ins_clublistingpics->registerTrigger("AFTER", "Trigger_ImageUpload", 97);
$ins_clublistingpics->registerConditionalTrigger("{GET.isFlash} == 1", "ERROR", "Trigger_Default_MUploadError", 10);
// Add columns
$ins_clublistingpics->setTable("clublistingpics");
$ins_clublistingpics->addColumn("UploadDate", "DATE_TYPE", "VALUE", "{now}");
$ins_clublistingpics->addColumn("ClubID", "NUMERIC_TYPE", "SESSION", "ClubID", "[sESSION.ClubID]");
$ins_clublistingpics->addColumn("DefaultPic", "STRING_TYPE", "VALUE", "Yes");
$ins_clublistingpics->addColumn("ImageFile", "FILE_TYPE", "FILES", "Filedata");
$ins_clublistingpics->setPrimaryKey("PicsID", "NUMERIC_TYPE");

// Execute all the registered transactions
$tNGs->executeTransactions();

// Get the transaction recordset
$rsclublistingpics = $tNGs->getRecordset("clublistingpics");
$row_rsclublistingpics = mysql_fetch_assoc($rsclublistingpics);
$totalRows_rsclublistingpics = mysql_num_rows($rsclublistingpics);

// Multiple Upload Helper Object
$muploadHelper = new tNG_MuploadHelper("", 32);
$muploadHelper->setMaxSize(4000);
$muploadHelper->setMaxNumber(0);
$muploadHelper->setExistentNumber(0);
$muploadHelper->setAllowedExtensions("gif, jpg, jpe, jpeg, png");
?>
<!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=utf-8" />
<title>Stuff2do - Club Registration</title>
<link href="css/screen.css" rel="stylesheet" type="text/css" />
<link href="includes/skins/mxkollection3.css" rel="stylesheet" type="text/css" media="all" />
<script src="includes/common/js/base.js" type="text/javascript"></script>
<script src="includes/common/js/utility.js" type="text/javascript"></script>
<script src="includes/skins/style.js" type="text/javascript"></script>
<?php echo $tNGs->displayValidationRules();?><?php echo $muploadHelper->getScripts(); ?>


</head>

<body class="oneColFixCtr">

<div id="container">
  <div id="mainContent">

    	<div id="CentralColumn">
<h2>UPLOAD CLUB IMAGES </h2> 
<p><?php if(isset($_SESSION['Address'])) echo $_SESSION['Address']; ?></p>
<div id="PrimaryPic">
		<?php
echo $tNGs->getErrorMsg();
?>
		<?php
// Multiple Upload Helper
echo $tNGs->getSavedErrorMsg();
echo $muploadHelper->Execute();
?>
</div>	
<div id="Pic1"></div>
</div>
<!-- end #mainContent --></div>
<!-- end #container --></div>
</body>
</html>

 

Link to comment
Share on other sites

Does it actually end up redirecting to the second page? Are both those files in the same folder?

 

Some possibilities -

 

The redirect occurs at a point before your code that is setting the session variable.

 

The redirect changes the hostname/subdomain (from domain.com to www.domain.com or visa versa) or it changes the path (which if the two files are in the same folder is not what is occurring.) If so, then the session cookie parameters would need to be set to cause the session cookie to match any change in hostname/subdomain and/or path.

 

It's possible buy unlikely that the form processing code is clearing $_POST['KT_Insert1'] so that you code to set the session variable is not being executed.

 

Register_globals are on and the session and post variables with the same name are causing the session variable to be nulled out.

 

Edit to match your new posted code -

 

if (!isset($_SESSION)) session_start(); is pointless, because $_SESSION won't exist until session_start() has been executed, so that line of code will always cause the session_start() to be executed.

 

I'm going to guess that you had a name mismatch between the form and the $_POST variable (no one is going to look through or compare that many lines of code to find what you changed in it.)

Link to comment
Share on other sites

Yes it does redirect to the second page (with no error messages).  Both files are in the same folder.

 

I have changed the Form 'Address' name to "Address1" and changed the code for setting the Address SESSION accordingly to:

 

if (isset($_POST['Address1'])) $_SESSION['Address'] = $_POST['Address1'];

 

But this has not fixed the problem:-(

 

I have tried setting the SESSION with a trigger so that i can be sure the SESSION is created before the redirect occurs using:

 

//start SESSION_SET_ADDRESS trigger
function SESSION_SET_ADDRESS(&$tNG) {
if (isset($_POST['Address'])) $_SESSION['Address'] = $_POST['Address'];
}
$ins_clubs->registerTrigger("STARTER", "Trigger_Default_Starter", 1, "POST", "KT_Insert1");
$ins_clubs->registerTrigger("END", "Trigger_Default_Redirect", 99, "Reg_Attract_Pics.php");
$ins_clubs->registerTrigger("BEFORE", "SESSION_SET_ADDRESS", 50);

 

But this does not work either.  BIG??? and :-( :-(

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.