1, establish conn.php
<?php[email protected]_connect ("127.0.0.1", "Root", "") or Die ("Connect False"); mysql_select_db ("Wikidb", $bbs); mysql_query ("Set names ' UTF8 '");? >
2, establish add.php
<?phpinclude ("conn.php"); if (Isset ($_post[' submit ')) { $sql = "insert into ' message ' (' ID ', ' user ', ' title ', ' content ', ' Lastdate ') VALUES (', ' $_post[user] ', ' $_post[title] ', ' $_post[content] ', now () ) "; mysql_query ($sql); echo " <script>alert (' Successful '); location.href= ' index.php ' </script> ';//When Delete is complete, return to home}?><form action= "add.php" Method= "POST" >user:<br /><input type= "text" size=10 name= "User" />< Br />title:<br /><input type= "text" name= "Title" /><br /> Content:<br /><textarea name= "Content" ></textarea><br /><input Type= "Submit" name= "Submit" value= "in" ></FORM>
3, establish list.php
<?phpinclude ("conn.php");? ><table width= "border=" 1 "align=" center "callpadding=" 0 "callspacing=" 0 "bgcolor=" white "><?php$sql= "Select ' id ', ' user ', ' title ', ' content ', ' lastdate ' from ' message ' ORDER by id desc"; $query =mysql_query ($sql); while ($row =mysql_fetch_array ($query)) {><tr bgcolor= "yellow" > <td>title:<?php echo $row [' Title ']?>user name:<?php echo $row [' user ']?></td></tr><tr bgcolor= ' #ffffff ' > <td>contents:<?php echo $row [' content ']?></td></tr><?php}?></table>
This article is from "Jerry" blog, be sure to keep this source http://alipay.blog.51cto.com/7119970/1537553