Jump to content

<select name=> not passing value


tjverge

Recommended Posts

<?php
$opid = $_GET['opid'];

$sql="Select * from `ships` WHERE `enabled` = 'Yes'";
$result = mysql_query($sql) or die (mysql_error());
echo "<form action=main.php?id=joinop.php&opid=".$opid." method=post> 
Ship Type: <select name = ship>";
while ($row = mysql_fetch_array($result)) {
echo "<option Value=".rawurlencode($row['shiptype']).">".$row['shiptype']."</option>";
}
echo "</select>
<input name=submit type=submit value=Join>
</form>";

if (isset($_POST['submit']))
{
$stype = rawurldecode($_Post['ship']);
$stime = date("G:i:s",time());
$sql="Select * from `ships` WHERE `shiptype` = '$stype'";
$result = mysql_query($sql) or die (mysql_error());
while ($row = mysql_fetch_array($result)) {
$weight = $row['weight'];
}
echo $stype;
mysql_query ("INSERT INTO `ccccomma_eve`.`userops` (`id` ,`starttime` ,`endtime` ,`shiptype` ,`weight` ,`payout` ,`active`) VALUES ('$opid', '$stime', '', '$stype', '$weight', '', 'Yes')") or die (mysql_error());
Echo "Op Joined";
}
?>

 

The variable is empty when I echo it out, any ideas on how to make to stick? Here is just the form that is giving me trouble

 

echo "<form action=main.php?id=joinop.php&opid=".$opid." method=post> 
Ship Type: <select name = ship>";
while ($row = mysql_fetch_array($result)) {
echo "<option Value=".rawurlencode($row['shiptype']).">".$row['shiptype']."</option>";
}
echo "</select>
<input name=submit type=submit value=Join>
</form>";

Link to comment
https://forums.phpfreaks.com/topic/227298-not-passing-value/
Share on other sites

Try using escaped quotes in your echo statment I.E

 

echo "<form action=\"main.php?id=joinop.php&opid=".$opid."\" method=\"post\">

Ship Type: <select name =\"ship\">";

 

the only other thing i could think of is that there is something wrong with the data fetched in your mysql_fetch_array($result) I would try a debug line after this statement echo out $result it should print a valid mysql result identifier

Link to comment
https://forums.phpfreaks.com/topic/227298-not-passing-value/#findComment-1172420
Share on other sites

<form action="main.php?id=joinop.php&opid=1" method="post">
Ship Type: <select name ="ship">Select * from `ships` WHERE `enabled` = 'Yes'<option Value=Test%20Ship%201>Test Ship 1</option>Select * from `ships` WHERE `enabled` = 'Yes'<option Value=Test%20Ship%202>Test Ship 2</option></select>

<input name=submit type=submit value=Join>
</form>

Link to comment
https://forums.phpfreaks.com/topic/227298-not-passing-value/#findComment-1172429
Share on other sites

my html output, code still doesn't work

 

<form action=main.php?id=joinop.php&opid=1 method=post>
Ship Type: <select name = ship><option Value=Test%20Ship%201>Test Ship 1</option><option Value=Test%20Ship%202>Test Ship 2</option></select>

<input name=submit type=submit value=Join>
</form>

Link to comment
https://forums.phpfreaks.com/topic/227298-not-passing-value/#findComment-1172438
Share on other sites

This should fix it.

echo "<option Value=\"{$row['shiptype']}\">{$row['shiptype']}</option>";

 

If it doesn't, add this to the top of the script, and post the output after submitting the form.

echo '<pre>';
print_r($_POST);
echo '</pre>';

Link to comment
https://forums.phpfreaks.com/topic/227298-not-passing-value/#findComment-1172441
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.