Madatan Posted June 6, 2006 Share Posted June 6, 2006 I've done this kind of things many times before... and yet I can't get it to work this time. The code down here simply wont send a value from the Form. Can anyone see why?[code]<?session_start();include 'dbconnect.php';$Button = $_SESSION['charactername'];$query = "SELECT * FROM mud_users WHERE name = '$Button'";$result = mysql_query($query) or die('Error : ' . mysql_error());$row = mysql_fetch_array($result, MYSQL_ASSOC);$rowid = $row['id'];//EQUIPif(isset($_POST['equip'])) {//Change don't get a value$query = "UPDATE mud_armour SET equipped = '1' WHERE arid = '$change'";$result = mysql_query($query) or die('Error : ' . mysql_error());}$query = "SELECT * FROM mud_armour WHERE ownerid = '$rowid' AND equipped = '0'"; //Torso$result = mysql_query($query) or die('Error : ' . mysql_error());while($row = mysql_fetch_array($result, MYSQL_ASSOC)) {?><tr><td><span class="style4"><b>Unequipped</b>:<br>Name: <? echo $row['name']; ?></span></td><td> </td><td> </td><td> </td><td><form id="yes" name="jak" method="post"><input name="add" type="text" value="<? echo $row['arid']; ?>">//This is change, it's supposed to get a value from the database. It does but it wont send the value.<input name="change" type="hidden" value="<? echo $row['arid']; ?>"><input name="equip" type="submit" value="Equip"></form></td></tr><? } ?></table>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/11318-form-wont-send-a-value/ Share on other sites More sharing options...
witt Posted June 6, 2006 Share Posted June 6, 2006 Shouldn't you have something like action="getform.php" ? Quote Link to comment https://forums.phpfreaks.com/topic/11318-form-wont-send-a-value/#findComment-42369 Share on other sites More sharing options...
Madatan Posted June 6, 2006 Author Share Posted June 6, 2006 [!--quoteo(post=380558:date=Jun 6 2006, 06:47 AM:name=witt)--][div class=\'quotetop\']QUOTE(witt @ Jun 6 2006, 06:47 AM) [snapback]380558[/snapback][/div][div class=\'quotemain\'][!--quotec--]Shouldn't you have something like action="getform.php" ?[/quote]no because the script I want to start is not in another php file but in the same... thats the reason why I use if(isset($_POST['attack']))when I click the button named attack it will do the code in that if statement. Quote Link to comment https://forums.phpfreaks.com/topic/11318-form-wont-send-a-value/#findComment-42403 Share on other sites More sharing options...
ober Posted June 6, 2006 Share Posted June 6, 2006 I'm going to guess it's because you're nesting a form inside of a table. Put your form tags outside of the table (you can obviously leave the input fields in the table) and see what happens.Also, it's good practice to put the action attribute in the form even if you're submitting to the same page.And I assume you mean "equip" instead of "attack", because that's how it is coded. Quote Link to comment https://forums.phpfreaks.com/topic/11318-form-wont-send-a-value/#findComment-42416 Share on other sites More sharing options...
Madatan Posted June 6, 2006 Author Share Posted June 6, 2006 [!--quoteo(post=380606:date=Jun 6 2006, 09:16 AM:name=ober)--][div class=\'quotetop\']QUOTE(ober @ Jun 6 2006, 09:16 AM) [snapback]380606[/snapback][/div][div class=\'quotemain\'][!--quotec--]I'm going to guess it's because you're nesting a form inside of a table. Put your form tags outside of the table (you can obviously leave the input fields in the table) and see what happens.Also, it's good practice to put the action attribute in the form even if you're submitting to the same page.And I assume you mean "equip" instead of "attack", because that's how it is coded.[/quote]Yes I mean equip of course :)I changed everything now, moving the form out of the table but I wont get a value anyway :/ so that didn't work. I guess I have to figure out something else! Quote Link to comment https://forums.phpfreaks.com/topic/11318-form-wont-send-a-value/#findComment-42420 Share on other sites More sharing options...
ober Posted June 6, 2006 Share Posted June 6, 2006 I think your error may be in your query:$query = "UPDATE mud_armour SET equipped = '1' WHERE arid = '$change'";Change it to:$query = "UPDATE mud_armour SET equipped = '1' WHERE arid = '" . $_POST['change'] . "'"; Quote Link to comment https://forums.phpfreaks.com/topic/11318-form-wont-send-a-value/#findComment-42427 Share on other sites More sharing options...
Madatan Posted June 6, 2006 Author Share Posted June 6, 2006 [!--quoteo(post=380617:date=Jun 6 2006, 09:51 AM:name=ober)--][div class=\'quotetop\']QUOTE(ober @ Jun 6 2006, 09:51 AM) [snapback]380617[/snapback][/div][div class=\'quotemain\'][!--quotec--]I think your error may be in your query:$query = "UPDATE mud_armour SET equipped = '1' WHERE arid = '$change'";Change it to:$query = "UPDATE mud_armour SET equipped = '1' WHERE arid = '" . $_POST['change'] . "'";[/quote]Thank you so much! I've been trying to get this to work the last 24 hours and it truly have made me insane. Quote Link to comment https://forums.phpfreaks.com/topic/11318-form-wont-send-a-value/#findComment-42433 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.