I always forget to make a word.
<Body bgcolor = "# 0080ff" ">
<Form action = "bbs. php" method = "Post" name = "form">
<Table border = 0 cellpadding = 2 cellspacing = 0>
<Tr>
<TD align = right> name: </TD>
<TD> <input type = text size = 40 name = ename value = ''maxlength = 50> </TD> </tr>
<Tr>
<TD align = right> Email: </TD> <input type = text size = 40 name = Email value = ''maxlength = 100> </TD>
</Tr>
<Tr>
<TD valign = Top align = right> message: </TD>
<TD> <textarea name = content rows = 4 Cols = 40 wrap = Virtual> </textarea> </TD>
</Tr>
<Tr>
<TD> </TD> <Div align = "center">
<Input type = submit value = 'add'> & nbsp;
<Input type = reset value = 'clear'> & nbsp;
</Div>
</TD>
</Tr>
<Tr>
<TD> </TD>
<TD> & nbsp; </TD>
</Tr>
</Table>
<Br>
<? PHP
// Connect to the database
$ Link = mysql_connect ('localhost', 'root ','');
If (! $ Link)
{
Die ('could not connect: '. mysql_error ());
}
Mysql_select_db ("BBS ");
// Judge whether the name is empty
If (! Empty ($ _ post ['ename'])
{
$ Ename = ($ _ post ['ename']);
$ Email = ($ _ post ['email ']);
$ Content = ($ _ post ['content']); // content indicates the content.
$ Postdate = getdate ();
// Define the SQL string from data to the BBS table
$ SQL = "insert into BBS (ename, email, content, postdate) values ('$ ename',' $ email ',' $ content', now ());";
// Execute the insert statement
Mysql_query ($ SQL );
Mysql_query ("commit ");
}
// Define and execute the SQL string inserted into the BBS table
$ Result = mysql_query ('select ID, ename, email, content,
Date_format (postdate, "% d % m % Y % H: % I: % s"), postdate from BBS order by ID DESC ');
// Determine whether the query is successful
If (! $ Result)
{
Die ('could not query: '. mysql_error ());
}
?>
<Br>
& Lt; HR size = 2 width = 80% & gt;
<Br>
<? PHP
$ Num_rows = mysql_num_rows ($ result );
If ($ num_rows> 0)
{
While ($ ROW = mysql_fetch_array ($ result, mysql_assoc ))
{
?>
<Table border = 0 cellpadding = 2 cellspacing = 0>
<Tr>
<TD align = right> <B> name: </B> </TD>
<TD>
<? PHP
Echo $ row ["ename"]; // obtain the name. This Code is in <TD>
?> </TD>
<Tr> <TD align = right> <B> Email: </B> </TD> <TD>
<? PHP
Echo $ row ["email"]; // output email address
?>
</TD> </tr>
<Tr>
<TD valign = Top align = right> <B> message: </B> </TD>
<TD width = 500>
<? PHP
Echo $ row ["content"]; // output the message content. This Code is in <TD>
?> </TD> </tr>
<Tr>
<TD> <Div align = "right"> <strong> date: </strong> </div> </TD>
<TD> <font size = 2>
<? PHP
Echo $ row ["postdate"]; // output the date to be added.
?> (GMT time) </font> </TD> </tr>
</Table>
<Br>
& Lt; HR size = 2 width = 80% & gt;
<Br>
<? PHP
}
}
Else
{
Echo "<B> <center> sorry, no database records read </center> </B> ";
}
Mysql_free_result ($ result );
?>
</Form>
<Br>
</Body>