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

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

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

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

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.