DrTrans Posted August 1, 2012 Share Posted August 1, 2012 I cant seem to figure out why this select wont post data to the form handler print"<td align=\"right\">Account:</td>"; print"<td> <select name=\"account\">"; get_connect(); $query = "SELECT * FROM chartofaccounts ORDER BY AccountNumber ASC"; $result = mysql_query($query); while($row = mysql_fetch_assoc($result)) { $accountnumber = $row['AccountNumber']; $name = $row['Name']; print "<option value=$accountnumber> $accountnumber $name </option>"; } print "</select>"; print "</td></tr>"; my form handler is: <?php $account = $_POST['account']; die($account); ?> Quote Link to comment https://forums.phpfreaks.com/topic/266568-select/ Share on other sites More sharing options...
Jessica Posted August 1, 2012 Share Posted August 1, 2012 You need to surround the value in double quotes, it's <option value="1">1</option> etc. On the form handler, do print_r($_POST); Quote Link to comment https://forums.phpfreaks.com/topic/266568-select/#findComment-1366114 Share on other sites More sharing options...
DrTrans Posted August 1, 2012 Author Share Posted August 1, 2012 I put in the double quotes.. nothing. Quote Link to comment https://forums.phpfreaks.com/topic/266568-select/#findComment-1366118 Share on other sites More sharing options...
Jessica Posted August 1, 2012 Share Posted August 1, 2012 Is that all I said to do? Weird, I'm sure I wrote more.... Quote Link to comment https://forums.phpfreaks.com/topic/266568-select/#findComment-1366119 Share on other sites More sharing options...
DrTrans Posted August 1, 2012 Author Share Posted August 1, 2012 print "<option value=\"$accountnumber\"> $accountnumber $name </option>"; Nothing came back on the print_r($_POST); Quote Link to comment https://forums.phpfreaks.com/topic/266568-select/#findComment-1366120 Share on other sites More sharing options...
Drongo_III Posted August 1, 2012 Share Posted August 1, 2012 Do you have errors turned off? Just wondering if you're not supressing an error? Quote Link to comment https://forums.phpfreaks.com/topic/266568-select/#findComment-1366121 Share on other sites More sharing options...
DrTrans Posted August 1, 2012 Author Share Posted August 1, 2012 if i change it to <input type=\"text\" name=\"account\" value =\"1\"> Comes back Array ( [account] => 1) ITS ONLY on the Select Quote Link to comment https://forums.phpfreaks.com/topic/266568-select/#findComment-1366122 Share on other sites More sharing options...
Christian F. Posted August 1, 2012 Share Posted August 1, 2012 I don't see a form in there, just a single select. Which leads me to believe that you're not using POST at all, but GET. Also, you should be using htmlspecialchars () and intval () to ensure that you're not open for HTML injections (XSS, CSRF etc). Meanwhile: The OP posts some new information, which sheds some more light on the situation, and raises more questions. So you are, apparently, using a form and you have several more fields in it. Would you please post the entire form-relevant code, so that we can actually see what happens instead of having to guess? Also, do a print_r () on the entire $_POST array. Quote Link to comment https://forums.phpfreaks.com/topic/266568-select/#findComment-1366123 Share on other sites More sharing options...
DrTrans Posted August 1, 2012 Author Share Posted August 1, 2012 Ill post the entire script: print"<form action=\"process.php?process=charge\" name=\"charge\" onSubmit=\"return validateForm();\" method=\"POST\">"; print"<tr>"; print"<td align=\"right\"><b>Property:</b></td>"; get_connect(); $query = "SELECT * FROM props WHERE propid = $propertyid and loginid = $loginid"; $result = mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_assoc($result)) { $propertyid = $row['propid']; $propertyname = $row['name']; $propertydesc = $row['description']; $propertyaddy = $row['address']; $propertycity = $row['city']; $propertystate = $row['state']; $propertyzip = $row['zip']; $tenantid = $row['tenantid']; $active = $row['active']; $lease = $row['lease']; $leaseamt = $row['leaseamt']; $owner_id = $row['ownerid']; } print"<td align=\"left\"><input type=\"hidden\" name=\"pay_property\" value=\"$propertyid\">$propertyaddy<br> $propertycity, $propertystate, $propertyzip</td>"; print"</tr>"; print"<tr>"; print"<td align=\"right\">Tenant:</td>"; print"<td align=\"left\"> <input type=\"hidden\" name=\"pay_tenant\" value=\"$tenantid\">$tenantid</td>"; print"</tr>"; print"<tr>"; print"<td align=\"right\"><input type=\"hidden\" name=\"pay_owner\" value=\"$owner_id\"></td>"; print"<td align=\"left\"></td>"; print"</tr>"; print"<tr>"; print"<td align=\"right\">Date/Time:</td>"; $current_date = date("Y-m-d"); print"<td align=\"left\"><input type=\"text\" class=\"input3\" name=\"pay_date\" value=\"$current_date\"></td>"; print"</tr>"; print"<tr>"; print"<td align=\"right\">Charge Amount:</td>"; print"<td align=\"left\"><input type=\"text\" class=\"input3\" name=\"pay_amount\" value=\"$leaseamt\"></td>"; print"</tr>"; print"<tr>"; print"<td align=\"right\">Charge Amount:</td>"; print"<td align=\"left\"><input type=\"text\" name=\"account1\"value=\"1\"></td>"; print"</tr>"; print"<tr>"; print"<td align=\"right\">Account:</td>"; print"<td><select name=\"account\">"; get_connect(); $query = "SELECT * FROM chartofaccounts ORDER BY AccountNumber ASC"; $result = mysql_query($query); while($row = mysql_fetch_assoc($result)) { $accountnumber = $row['AccountNumber']; $name = $row['Name']; print "<option value=\"$accountnumber\">$accountnumber $name </option>"; } print "</select>"; print "</td></tr>"; print"<tr>"; print"<td align=\"right\>Notes/td>"; print"<td align=\"left\"></td>"; print"</tr>"; print"<tr>"; print"<td align=\"left\" colspan=\"2\"><textarea name=\"pay_message\" cols=\"55\" rows=\"10\"> </textarea></td>"; print"</tr>"; print"<tr>"; print"<td align=\"right\</td>"; print"<td align=\"center\"></td>"; print"<tr>"; print"<td align=\"left\" colspan=\"2\"><input type=\"submit\" name=\"submit\" value=\"Charge Account\"></td>"; print"</tr>"; print"</tr>"; print "</form>"; print"</table>"; } process.php?process=charge if($process == "charge"){ print_r($_POST); } The print_r($_POST) : Array ( [pay_property] => 256 [pay_tenant] => 23 [pay_owner] => 5 [pay_date] => 2012-08-01 [pay_amount] => 600 [account1] => 1 [pay_message] => [submit] => Charge Account ) 1 Quote Link to comment https://forums.phpfreaks.com/topic/266568-select/#findComment-1366126 Share on other sites More sharing options...
DrTrans Posted August 1, 2012 Author Share Posted August 1, 2012 Its only the Select box....however, my <select> in other forms work fine Quote Link to comment https://forums.phpfreaks.com/topic/266568-select/#findComment-1366146 Share on other sites More sharing options...
Jessica Posted August 2, 2012 Share Posted August 2, 2012 Put the process parameter as a hidden input, and check for $_POST['process'];, not $process. Quote Link to comment https://forums.phpfreaks.com/topic/266568-select/#findComment-1366264 Share on other sites More sharing options...
PFMaBiSmAd Posted August 2, 2012 Share Posted August 2, 2012 edit: never mind, in case you saw what I posted as a reply Quote Link to comment https://forums.phpfreaks.com/topic/266568-select/#findComment-1366271 Share on other sites More sharing options...
Jessica Posted August 2, 2012 Share Posted August 2, 2012 Also check the source of the page in your browser and make sure there is nothing weird being output there that would break it. Quote Link to comment https://forums.phpfreaks.com/topic/266568-select/#findComment-1366272 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.