Reputation: 21
I have a delete script on my dashboard that WAS working before moving domains.
( not sure if that is relevant )
The code for my 'deletejob.php' is below.
<?php
error_reporting(0);
$host = 'localhost';
$port = 3306;
$database = 'database';
$username = 'username';
$password = 'password';
$UID = $_POST["ID"];
// Connect to the database
$dsn = "mysql:host=$host;port=$port;dbname=$database";
$db = new PDO($dsn, $username, $password); // connect
$Query = "DELETE FROM joblist WHERE ID='$UID'";
// Do a query thingy whatever its called
$statement = $db->prepare($Query);
$statement->execute();
while ($result = $statement->fetchObject()) {}
?>
The script functions as if it is working and even gives me the alert
( ID has been successfully deleted. )
Does anyone have any idea as to why this script would return a false positive?
Upvotes: 1
Views: 2918
Reputation: 219
You must find the row you want to delete, using SELECT statement, like this:
$stmt= $conn->query("SELECT * FROM users WHERE id='".$_REQUEST['ids']."'");
Also You have to have the following sent when you click the delete button or it will not delete at all:
<input type="hidden" name="id" value="<?php echo $_REQUEST['ids'];?>">
After the above:
$stmt= $conn->query("DELETE FROM users Where id = '".$_REQUEST['id']."'");
Upvotes: 1