-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprocess_post.php
More file actions
28 lines (24 loc) · 927 Bytes
/
Copy pathprocess_post.php
File metadata and controls
28 lines (24 loc) · 927 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
27
28
<?php
session_start();
require "helper.php";
$db = database();
if(isset($_SESSION["id"])){
$userID = $_SESSION["id"];
$q = $db->query("SELECT email, verified, id FROM users WHERE id= $userID");
$q = $q->fetchAll();
$title = $_POST["title"];
$body = $_POST["body"];
$classid = $_POST["cid"];
$posterid = $q[0]["id"];
if(getDomain($q[0]["email"]) === "????" && $q[0]["verified"] === '1' && strlen(trim($title)) !== 0 && strlen(trim($body)) !== 0){
$body = sanitize($body);
$title = sanitize($title);
$newPost = $db->prepare("INSERT INTO posts (posterid, title, body, classid) VALUES (:posterid, :title, :body, :classid)");
$newPost->execute(array("posterid" => $posterid, "title" => $title, "body" => $body, "classid" => $classid));
}
else
header("location:index.php");
}
else
header("location:index.php");
header("location:discussion.php");