-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAddFreind.php
More file actions
26 lines (24 loc) · 885 Bytes
/
AddFreind.php
File metadata and controls
26 lines (24 loc) · 885 Bytes
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
<?php
session_start();
if (!isset($_SESSION['username'])){
header("Location:index.php");
die();
}else{
include("connectdb.php");
include("function.php");
if (isset($_POST['addFreind'])){
$freindID = validInput($_POST['FreindID']);
$userId = selectDatabase($conx,'id',$_SESSION['username'],'users');
$preparing = $conx->prepare("INSERT INTO freind (freind_id,user_id) VALUES (?,?)");
$preparing->execute(array($freindID,$userId));
}
else if (isset($_POST['removeFreind'])){
$freindID = validInput($_POST['FreindID']);
$userId = selectDatabase($conx,'id',$_SESSION['username'],'users');
$preparing = $conx->prepare("DELETE FROM freind WHERE freind_id = ? AND user_id = ? ");
$preparing->execute(array($freindID,$userId));
}
header("Location:home.php");
die();
?>
<?php } ?>