-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathinsertWallpost.php
37 lines (29 loc) · 914 Bytes
/
insertWallpost.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
<?php
/* start the session */
session_start();
if(!isset($_SESSION['id'])) {
header("Location: index.php?id=login-form");
}
/* require credentials! */
require "db.conf";
/* connect to database */
$link = mysqli_connect($dbhost, $dbuser, $dbpass, $dbname);
/* check connection */
if (!$link){
printf("Connect failed: %s\n", mysqli_connect_error());
}
$id = $_SESSION['id'];
$body = $_POST['wallpost'];
$sql3 = "INSERT INTO Wallpost (id, postTime, body) VALUES (?, now(), ?)";
/* create a prepared statement */
if ($stmt3 = mysqli_prepare($link, $sql3)){
/* bind variables to marker */
mysqli_stmt_bind_param($stmt3, "ss", $id, $body) or die("bind param");
/* execute query */
mysqli_stmt_execute($stmt3);
/* close the prepared statement */
mysqli_stmt_close($stmt3);
/* redirect back to profile page */
header("Location: index.php?id=profile");
} else echo "Prepared statement 3 failed.";
?>