-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunction.php
More file actions
57 lines (33 loc) · 1.27 KB
/
Copy pathfunction.php
File metadata and controls
57 lines (33 loc) · 1.27 KB
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
54
55
56
57
<?php
include "db.php";
function gettopics (){
GLOBAL $conn;
$sqli="SELECT * from topic";
$res=mysqli_query($conn, $sqli);
while ($row=mysqli_fetch_array($res)) {
$topic_id=$row['topic_id'];
$topic_name=$row['topic_name'];
echo "<option value ='$topic_id'>$topic_name</option>";
}
}
function insertpost(){
if (isset($_POST['sub'])) {
global $conn;
global $user_id;
$title =addslashes ($_POST['title']);
$content =addslashes($_POST['content']);
$topic=$_POST["topic"];
if ($content=='' && $title=='') {
echo "<script>alert('failed')</script>";
exit();
}else {
$sqli="INSERT into postss (user_id,topic_id,post_title,post_content,post_date) values ('$user_id','$topic','$title', '$content', NOW())";
$rese=mysqli_query($conn, $sqli);
if ($rese) {
$updates="UPDATE usern set posts='yes' where user_id='$user_id '";
$reset=mysqli_query($conn, $updates);
}
}
}
}
?>