-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadd_joke.php
More file actions
35 lines (25 loc) · 1.09 KB
/
add_joke.php
File metadata and controls
35 lines (25 loc) · 1.09 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
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
session_start();
if(! $_SESSION['userid']) {
echo "Only logged in users can add a joke. Click <a href='google_login.php' </a>here to login<br>";
exit;
}
include "db_connect.php";
$newjokequestion = addslashes($_GET['newjoke']);
$newjokeanswer = addslashes($_GET['jokeanswer']);
$newjokequestion = addslashes($newjokequestion);
$newjokeanswer = addslashes($newjokeanswer);
$userid = $_SESSION['userid'];
echo "<h2>New Joke Added: $newjokequestion - $newjokeanswer</h2>";
$sql = "INSERT INTO Jokes_table (JokeID, Joke_question, Joke_answer, users_ID) VALUES (NULL, '$newjokequestion', '$newjokeanswer', '$userid')";
$result = $mysqli->query($sql) or die(mysqli_error($mysqli));
include "search_all_jokes.php";
// $stmt = $mysqli->prepare("INSERT INTO Jokes_table (JokeID, Joke_question, Joke_answer, users_ID) VALUES (NULL, ?, ?, ?)");
// $stmt->bind_param("ssi", $newjokequestion, $newjokeanswer, $userid);
//
// $stmt->execute();
// $stmt->close();
?>
<a href="index.php">Return to main page</a>