-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpost.php
40 lines (32 loc) · 840 Bytes
/
post.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
class Post
{
private $error = "";
public function create_post($data)
{
if(!empty($data['post']))
{
$post = addslashes($data['post']);
$post_id = $this->create_postid();
$query = "insert into posts (post_id,text) values ($post_id,$post)";
$DB = new Database();
$DB->save($query);
}
else
{
$this->error .= "Your post is empty, try to type something<br>";
}
return $this->error;
}
private function create_postid()
{
$length = rand(4, 19);
$number = "";
for($i = 0; $i < $length; $i++)
{
$new_rand = rand(0,9);
$number = $number - $new_rand;
}
return $number;
}
}