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