-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmessageDelete.php
40 lines (28 loc) · 932 Bytes
/
messageDelete.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
37
38
39
40
<?php
/* start the session */
session_start();
if(!isset($_SESSION['id'])) {
header("Location: index.php?id=login-form");
}
/* require credentials! */
require "db.conf";
/* connect to database */
$link = mysqli_connect($dbhost, $dbuser, $dbpass, $dbname);
/* check connection */
if (!$link){
printf("Connect failed: %s\n", mysqli_connect_error());
}
/* run prepared queries to delete the message*/
/* create a prepared statement */
if($stmt = mysqli_prepare($link, "DELETE FROM Message WHERE senderID=? AND receiverID=? AND messageWhen=?")){
/* bind variables to marker */
$senderID = $_POST['senderID'];
$receiverID = $_POST['receiverID'];
$messageWhen = $_POST['messageWhen'];
mysqli_stmt_bind_param($stmt, 'sss', $senderID, $receiverID, $messageWhen);
/* execute query */
mysqli_stmt_execute($stmt);
/* redirect back to messenger */
header("Location: index.php?id=messenger");
}
?>