-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadd-group.php
45 lines (34 loc) · 866 Bytes
/
add-group.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
41
42
43
44
45
<?php
session_start();
include "functions.php";
include 'database/connect.php';
include 'langCheck.php';
protect();
$name = $_POST['name'];
if(empty($name)){
echo $lang['groupNameCantBeEmpty'];
exit();
}
$user = $_SESSION['user'];
$query = $con->prepare("SELECT user_id FROM users WHERE username = ?");
$query->bind_param("s", $user);
$query->execute();
$query->bind_result($id);
$query->fetch();
$query->close();
$query = $con->prepare("SELECT * FROM groups WHERE name = ? AND user_id = ?");
$query->bind_param("ss", $name, $id);
$query->execute();
$query->store_result();
$nm = $query->num_rows;
$query->close();
if($nm > 0){
echo $lang['groupNameTaken'];
exit();
}
$query = $con->prepare("INSERT INTO groups VALUES('', ?, ?)");
$query->bind_param("ss", $name, $id);
$query->execute();
$query->close();
echo "ok";
?>