-
Notifications
You must be signed in to change notification settings - Fork 0
/
setters.php
53 lines (49 loc) · 1.24 KB
/
setters.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
46
47
48
49
50
51
52
53
<?php
/**
* Creates a new user in the database.
*
* @param string $name
* @param string $email
* @param string $password
* @return boolean
*/
function createUser($name, $email, $password) {
global $mysqli;
if ($mysqli->query("INSERT INTO users (name, email, password) VALUES ('$name', '$email', '$password')")) {
return true;
}
return false;
}
/**
* Creates a new post in the database.
*
* @param integer $author_id
* @param string $title
* @param string $body
* @return boolean
*/
function createPost($author_id, $title, $body) {
global $mysqli;
if ($mysqli->query("INSERT INTO posts (author_id, title, body, created_at) VALUES ('$author_id', '$title', '$body', NOW())")) {
return true;
}
return false;
}
/**
* Creates a new comment in the database.
*
* @param integer $post_id
* @param integer $user_id
* @param string $name
* @param string $email
* @param string $body
* @return boolean
*/
function createComment($post_id, $user_id, $name, $email, $body) {
global $mysqli;
if ($mysqli->query("INSERT INTO comments (post_id, user_id, name, email, body, created_at) VALUES ('$post_id', '$user_id', '$name', '$email', '$body', NOW())")) {
return true;
}
return false;
}
?>