-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathinfo.php
More file actions
44 lines (33 loc) · 936 Bytes
/
info.php
File metadata and controls
44 lines (33 loc) · 936 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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
$text = $_POST["body"];
$host = "localhost";
$dbname = "gatorbookdb";
$username = "root";
$password = "password";
function test_input($data)
{
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
$conn = mysqli_connect($host, $username, $password, $dbname);
if (mysqli_connect_errno()) {
die("Connection Error: " . mysqli_connect_error());
}
$sample_username = "johndoe2";
$sql_1 = "SELECT * FROM user WHERE username = '$sample_username'";
$result = mysqli_query($conn, $sql_1);
if (mysqli_num_rows($result) > 0) {
$sql = "INSERT INTO public_post (body)
VALUES (?)";
$stmt = mysqli_stmt_init($conn);
if (! mysqli_stmt_prepare($stmt, $sql)) {
die(mysqli_error($conn));
}
mysqli_stmt_bind_param($stmt, "s", $text);
mysqli_stmt_execute($stmt);
echo "Post saved.";
} else {
echo "your username was not found, you are not a user of gatorbook";
}