0

hi there

im a novice to PHP and have been trying to put together a form with two buttons that post a variable value. The value is tested and then php perfroms whatever action that value points to (Update or Delete). My problem is that when I click the button, the record is still there and I get no feedback inspite of having established it in the code:

Here are the buttons (called through include):

<form action="update_delete.php" method="post">
       Player I.D. <input type="text" name="pid" maxlength=10 size=5><br>
<input type="Submit" value="Delete" name="Delete">
<input type="Submit" value="Update" name="Update">
</form>

And here is the PHP:

<?php require_once("includes/connection.php"); ?>
<?php

$pid = $_POST['pid'];

if(isset($Update))
{
  //Update stuff
}
else
if(isset($Delete))
{
  $sql = "DELETE from player where id=$pid";
  $result = mysql_query($sql, $connection)
  or die("Database query failed: " . mysql_error());
  echo "Row deleted!";
}
?>

<?php require("includes/footer.php"); ?>

I'm not sure what to apply here...

3
Contributors
3
Replies
4
Views
8 Years
Discussion Span
Last Post by KJATL
0

You should check isset($_POST) instead of $Delete

Brilliant, thank you! This helped me get back on track.

0

You should check isset($_POST) instead of $Delete

Ack, awfully bone-headed of me. Thank you for your fresh-set of eyes.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.