Problem with insert , delete data into table from database

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

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

2 Likes

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

  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.

1 Like

thank you for the answer.

Sponsor our Newsletter | Privacy Policy | Terms of Service