-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdelete.php
36 lines (26 loc) · 945 Bytes
/
delete.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php
//Create delete record function
function deleteRecord(){
$servername = 'localhost';
$username = 'root';
$password = '';
$databasename = 'movieflix_database';
//Creating a Connection
$connection = mysqli_connect($servername, $username, $password, $databasename);
//Storing User input into variables
$id = $_POST['delete-id'];
//Attempting to INSERT data into table
$sql = "DELETE FROM movieflix_table WHERE id = '$id'";
//check if inserting data was successful
if(!mysqli_query($connection, $sql)){
echo 'Error : '.$sql.mysqli_error($connection);
}
//Close the connection
mysqli_close($connection);
//Redirect to main page index.php
header('location: index.php');
}
if(isset($_POST['submit-delete'])){
deleteRecord();
}
?>