-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpostupdate.php
44 lines (39 loc) · 1.31 KB
/
postupdate.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
<?php
//Database Connection Code
require_once('dbConnect.php');
$sql = dbConnect();
session_start();
if (!isset($_SESSION['email'])) {
if (isset($_COOKIE['email']) && isset($_COOKIE['auth'])&& isset($_COOKIE['id'])) {
$_SESSION['email'] = $_COOKIE['email'];
$_SESSION['auth'] = $_COOKIE['auth'];
$_SESSION['id'] = $_COOKIE['id'];
}
}
if (!isset($_SESSION['email'])) {
$home_url = 'index.php';
header('Location: ' . $home_url);
}
if (isset($_POST['submit'])) {
$id=$_SESSION['id'];
// Grab the user-entered log-in data
$tname = $_POST['tname'];
$pc = $_POST['pc'];
$pid = $_POST['postid'];
if (!empty($tname) && !empty($pc)) {
// Look up the username and password in the database
$query = "UPDATE `test`.`post` SET `topicname` = '$tname', `postcontent` = '$pc' WHERE `post`.`id` = $pid";
$data = mysqli_query($sql,$query);
mysqli_close($sql);
$home_url = 'forum.php';
header('Location:' . $home_url);
}
else {
// The username/password are incorrect so set an error message
echo 'Sorry, pls try again.';
}
}else{
$home_url = 'index.php';
header('Location: ' . $home_url);
}
?>