Update Delete sql-data with form field
Posted: 21 Sep 2016, 14:38
I wanna Delete records from a database, but i want to choose what record i delete into an text-area with delete-button
(i where able to find this code)
- Also, how can I make update, the code is wrong but something like this i mean
(i where able to find this code)
Code: Select all
<?php
// connect to the "tests" database
$conn = new mysqli('localhost', 'root', 'pass', 'tests');
// check connection
if (mysqli_connect_errno()) {
exit('Connect failed: '. mysqli_connect_error());
}
// DELETE sql query
$sql = "DELETE FROM `users` WHERE `name`='MarPlo'";
// perform the query and check for errors
if (!$conn->query($sql)) {
echo 'Error: '. $conn->error;
}
$conn->close();
?>
Code: Select all
// UPDATE sql query
$sql = "UPDATE `users` SET `email`='<form action="Testing.php" method="post"><input type="text" value="'. $row['name']. '" name="name" /><input type="submit" value="Send" /></form>' WHERE `name`='MarPlo' AND `id`=2";