-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcomment_page.php
98 lines (66 loc) · 1.82 KB
/
comment_page.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<?php
$name_entered= $_POST['name'];
$comment_entered= $_POST['comment'];
$table= $_POST['webpage'];
$date= date("m-d-Y");
$user = "user";
$password = "password";
$host = "host";
$dbase = "database";
$connection= mysql_connect ($host, $user, $password);
if (!$connection)
{
die ('Could not connect:' . mysql_error());
}
mysql_select_db($dbase, $connection);
$val = mysql_query("select 1 from $table");
if($val !== FALSE)
{
if ((!empty($name_entered)) && (!empty($comment_entered)))
{
mysql_query("INSERT INTO $table (name, date, comments)
VALUES ('$name_entered', '$date', '$comment_entered')");
}
$result= mysql_query( "SELECT * FROM $table ORDER BY ID DESC" )
or die("SELECT Error: ".mysql_error());
while ($row = mysql_fetch_array($result)){
$name_field= $row['name'];
$date_field= $row['date'];
$comment_field= $row['comments'];
echo "$name_field wrote: ($date_field) <br>";
echo "$comment_field";
echo "<br><hr><br>";
}
}
else
{
$createtable= "CREATE TABLE $table
( ".
"ID INT NOT NULL AUTO_INCREMENT, ".
"name VARCHAR(50) NOT NULL, ".
"date VARCHAR(50) NOT NULL, ".
"comments VARCHAR(60000) NOT NULL, ".
"PRIMARY KEY (ID)
);
";
$create= mysql_query($createtable, $connection);
if ($create)
{
if ((!empty($name_entered)) && (!empty($comment_entered)))
{
mysql_query("INSERT INTO $table (name, date, comments)
VALUES ('$name_entered', '$date', '$comment_entered')");
}
$result= mysql_query( "SELECT * FROM $table ORDER BY ID DESC" )
or die("SELECT Error: ".mysql_error());
while ($row = mysql_fetch_array($result)){
$name_field= $row['name'];
$date_field= $row['date'];
$comment_field= $row['comments'];
echo "$name_field wrote: ($date_field) <br>";
echo "$comment_field";
echo "<br><hr><br>";
}
}//if createtable
}//else
?>