-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpost.php
More file actions
30 lines (24 loc) · 867 Bytes
/
post.php
File metadata and controls
30 lines (24 loc) · 867 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
<?php
session_start();
$hostname = "localhost";
$username = "db";
$password = "db";
$dbName = "forum";
$dt = date('Y-m-d H:i:s');
$title = $_POST['theme_title'];
$text = $_POST['theme_text'];
$userid = $_SESSION['user_id'];
$msgtable = "messages";
$usrtable = "users";
$topicstable = "topics";
mysql_connect($hostname, $username, $password) OR DIE("unable to connect to database ");
mysql_select_db($dbName) or die(mysql_error());
$res = mysql_query("select count(1) FROM $topicstable");
$row = mysql_fetch_array($res);
$id = $row[0] + 1;
$query = "INSERT INTO $topicstable VALUES('$id','$dt','$title','$userid')";
mysql_query($query) or die(mysql_error());
$query = "INSERT INTO $msgtable VALUES('1','$id','$dt','$userid','$text')";
mysql_query($query) or die(mysql_error());
echo '<meta http-equiv="refresh" content="0;URL=viewtopic.php?topic=' .$id. '">';
?>