get wrong post value from drop down query options

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
dickm
Forum Newbie
Posts: 2
Joined: Thu Jun 03, 2010 11:36 pm

get wrong post value from drop down query options

Post 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
Last edited by Benjamin on Fri Jun 04, 2010 12:37 am, edited 1 time in total.
Reason: Added [syntax=php] tags.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: get wrong post value from drop down query options

Post 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?
User avatar
zeus1
Forum Newbie
Posts: 22
Joined: Tue May 18, 2010 10:45 pm
Location: /Under/The/AppleTree.png

Re: get wrong post value from drop down query options

Post 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>';
dickm
Forum Newbie
Posts: 2
Joined: Thu Jun 03, 2010 11:36 pm

Re: get wrong post value from drop down query options

Post 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
internet-solution
Forum Contributor
Posts: 220
Joined: Thu May 27, 2010 6:27 am
Location: UK

Re: get wrong post value from drop down query options

Post by internet-solution »

use quotes to enclose value in input element. see earlier post by zeus
Post Reply