Page 1 of 1

get wrong post value from drop down query options

Posted: Thu Jun 03, 2010 11:57 pm
by dickm
New to PHP and working with an Xamp installation of PHP 5.3.1 and MYSQL 5.1.41 on an XP system and developing with LOCALHOST

This is the small code section that is causing me the problem:

Code: Select all

 	<p><b>Special Notes :</b> <textarea name="comments"   
		 rows="3" cols="40">
        </textarea>
 	</fieldset>
 	</p> <hr />  <br /> 
 
                     
 
 	<?php
 
		require_once ('./php/mysql_connect.php'); // Connect to the db.
 		$cusid=$_SESSION['cusid'];
 		 $query="SELECT relcusid, concat(authsign,' [', signtitle, ']') as [b]mysig[/b] FROM relsignor
 			WHERE relcusid=$cusid";
		$result = mysql_query ($query);
		echo "<select name = [b]mysig [/b]value=''>[b]mysig[/b]</option>";
		 // printing the list box select command
 
		while($nt=mysql_fetch_array($result)){//Array or records stored in $nt
		echo "<option value=$nt[relcusid]>$nt[[b]mysig[/b]]</option>";
		/* Option values are added by looping through the array */
	 }
		echo "</select>";// Closing of list box 
	?>  
	<p><b>Signature to use: </b> </p><br />  
	<hr /> 
 
 	<div align="center"><input type="submit"
 	name="submit" value="Submit My Information" />
    <input type="hidden" name="submitted" value="TRUE" />
 	</div>
</form>
The upper portion of this code is and that is where the next session values are being created and saved:

if (isset($_POST['submitted'])) {

$_SESSION['comments']=$_REQUEST['comments']; //this value is being returned and stored correctly.
$_SESSION['mysig']=$_REQUEST['mysig']; //This is the problem value as it is returning the "relcusid" instead of "mysig"

So problem is I am getting the customer cusid value instead of the username and title value that is to be inserted in the next form.

Mahalo for your help

Re: get wrong post value from drop down query options

Posted: Fri Jun 04, 2010 12:24 am
by requinix
dickm wrote:This is the problem value as it is returning the "relcusid" instead of "mysig"
Well... yeah.

Code: Select all

echo "<option value=$nt[relcusid]>$nt[mysig]</option>";
See how you use the relcusid for the option value?

Re: get wrong post value from drop down query options

Posted: Fri Jun 04, 2010 1:05 am
by zeus1
1. The value you have for mysig is equal to $nt["relcusid"] not the value you are looking for
To correct it:

Code: Select all

echo '<option value=" ' . $nt["mysig"]. ' "> '. $nt["mysig"] .' </option>';

Re: get wrong post value from drop down query options

Posted: Fri Jun 04, 2010 2:50 pm
by dickm
Mahalo ZEUS, it is now partially working, however it is only storing part of the value.

Value in field (authsign) is JR WALLENQUICK and value in field (signtitle) is TREASURER. With the CONCAT the value of mysig should be
JR WALLENQUICK[TREASURER] but the value being printed out on the next form is JR. For a test I removed the JR in the Authsign field and then the value printed on the form was WALLENQUICK[TREASURER]. So the problem is with the space in the name. How is this solved? Mahalo

Re: get wrong post value from drop down query options

Posted: Sat Jun 05, 2010 5:52 am
by internet-solution
use quotes to enclose value in input element. see earlier post by zeus