Problem with insert , delete data into table from database


#1
<?php
include_once 'database.php';

$username= $_POST['username'];
$pass= $_POST['password'];

mysqli_query($conn ,"DELETE FROM mytable2 ( username , password) values ('{$_POST['username']}','{$_POST['password']}') ");


echo "DELETE FROM mytable2 ( username , password) values ('{$_POST['username']}','{$_POST['password']}')";

?>

<?php
include_once 'database.php';


$username= $_POST['username'];
$pass= $_POST['password'];

mysqli_query($conn ,"INSERT INTO mytable2 ( username , password) values ('{$_POST['username']}','{$_POST['password']}') ");
echo "INSERT INTO mytable2 ( username , password) values ('{$_POST['username']}','{$_POST['password']}')";
?>

none of them works , i don t understand why


#2

For starters, what are you trying to do? Because some of those things are wrong, and some of those things are really wrong.


#3

i try to add data , delete data from a table from database through a html form …


#4
  1. You never store a password in plain text.
  2. You never trust data a user sends you.

The syntax for the delete statement is incorrect.
Go through the tutorial I posted on how to interact with the database.


#5

thank you for the answer.