forked from Webwiznitr/Project-daffodil
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwriteDB.php
More file actions
35 lines (27 loc) 路 1005 Bytes
/
Copy pathwriteDB.php
File metadata and controls
35 lines (27 loc) 路 1005 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
<?php
//define the database connection variables
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "ForumDB";
try{
//create a connection object
$connection = new PDO("mysql:host=$servername;dbname=$dbname", $username,$password);
//set the PDO error mode to exception
$connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$_SERVER["REQUEST_METHOD"];
if ($_POST['add']){
$email = $_POST['email'];
$title = $_POST['title'];
$contents = $_POST['contents'];
$InsertData = $connection -> exec ("INSERT INTO Posts (Email,Title,Contents,Date_Time) VALUES
('$email','$title','$contents',NOW())");
echo "Add Post successfully.";
}
header( "refresh:1; forum.php" );
}
catch(PDOException $e)
{
echo "Connection failed: " . $e->getMessage();
}
?>