Jump to content

Form wont send a value


Madatan

Recommended Posts

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'];
//EQUIP


if(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>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</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]
Link to comment
Share on other sites

[!--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.
Link to comment
Share on other sites

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.
Link to comment
Share on other sites

[!--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!
Link to comment
Share on other sites

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'] . "'";
Link to comment
Share on other sites

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