dimanche 29 septembre 2019

Why does DELETE command doesn't work after INSERT is done?

I fetched this data from table1 into form input value and tried to INSERT to table2. Then I want it to be deleted from table1. But the DELETE doesn't work after INSERT is done. Is there any way to do same without IF? How? See I tried this:

<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "lock_access";

$conn = mysqli_connect($servername, $username, $password);

if(!$conn)
{ echo 'Not connected'; 
}
if(!mysqli_select_db($conn,$dbname))
{
    echo 'DB Not selected'; }

$fn = $_POST['full_name'];
$fln = $_POST['flatno'];
$gn = $_POST['gender'];
$pcn = $_POST['pcardno'];

$sql = "INSERT INTO approved (full_name, flat_number, gender, new_card) VALUES('$fn', '$fln', '$gn', '$pcn')";


if(mysqli_query($conn, $sql))
{

     DELETE FROM lock_access WHERE full_name='$fn';
}

else {
     echo "Application not received. ";
}

?>

Aucun commentaire:

Enregistrer un commentaire