post
poster: Xorm
description: messages.php (why broke? :< )
language: PHP
[download]
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
<HTML>

<?php

if($submit)

{
    $db = mysql_connect("localhost", "root", "mypassword");
    mysql_select_db("learndb",$db);
    $sql = "INSERT INTO messages (message) VALUES ('$message')";
    $result = mysql_query($sql);
    
    echo "Record added!";

}

else
{    
    $db = mysql_connect("localhost", "root", "mypassword");
    mysql_select_db("learndb",$db);
    $result = mysql_query("SELECT * FROM messages", $db);
    while ($myrow = mysql_fetch_array($result))
    {
    echo $myrow["id"];
    echo ".)_ ";
    echo $myrow["message"];
    echo "<br>";
    }

    ?>
    
    <form method="get" action="messages.php">
    <input type="text" name="message">
    <input type="submit" name="submit" value="Post"></form>
    <br>
    
    <?
}

?>

</HTML>