PHP-Small micro-blogging system

Source: Internet
Author: User

Effect:

Database:

Project structure:

add.php: Add Weibo.

conn.php: Database configuration file.

delete.php: Delete the blog code.

disinfo.php: Displays micro-blog details.

index.php: Home page.

update.php: Editorial Weibo.

add.php:

<?php//Introduction of database Connection file require (' conn.php ');//Determine whether to submit data if (!empty ($_post[' Sub ')) {//Receive data $title = $_post[' title '];$ Content = $_post[' content '];//determine when to fill in the information if ($title = = ' | | $content = = ') {echo ' Please fill in the complete information! '; exit ();} SQL statement $sql = "INSERT into ' tb_article ' (' title ', ' DateTime ', ' content ') VALUES (' $title ', now (), ' $content ')";// Executes and determines whether to execute successfully if (@mysql_query ($sql) or Die (' SQL execution exception! ') {echo ' <script Language=javascript>alert ("published successfully!) "); Window.location.replace (" index.php ") </script> ';}}? >

conn.php:

<?php//Connect database server @mysql_connect (' localhost:3306 ', ' root ', ' 123456 ') or Die (' Connect database server failed! ')///Select Database @mysql_select_db (' Db_weibo ') or Die (' Select database failed! ');//Set Encoding @mysql_query ("Set NAMES ' UTF8 '") or Die (' Database encoding error! ‘);? >

delete.php:

<?php//introduction of database connection require (' conn.php ');//Receive index.php page passed Idif (!empty ($_get[' id ')) {//Receive data $id = $_get[' id '];// SQL statement $sql = "DELETE from ' tb_article ' WHERE ID = ' $id ' limit 1 ';//execute if (@mysql_query ($sql) or Die (' SQL statement execution failed! ') {echo ' <script >alert ("Delete succeeded!) "); Window.location.replace (" index.php ") </script> '; exit ();}? >

disinfo.php:

<?php//Introduction of database Connection file require (' conn.php ');//Receive Idif (!empty ($_get[' id ')) {//Receive data $id = $_get[' id '];//sql statement $sql = "Select * from ' tb_article ' WHERE id = ' $id ' limit 1 ';//get resource handle $queryhandle = @mysql_query ($sql) or Die (' SQL execution failed! ');//Get one row of data $result = Mysql_fetch_array ($queryhandle, MYSQL_ASSOC);//sql statement (Modify click) $sql = "UPDATE" tb_article ' SET ' click ' = ' click ' +1 WHERE id = ' $id ';//execute and determine whether the execution succeeds @mysql_query ($sql) or Die (' SQL execution exception! ‘);}? >

index.php:

<?php//Introduction of database Connection file require (' conn.php ');//Get search field $keys = $_post[' Keys ']; Determine if there is a value if (Empty ($keys)) {$s = ';} else {$s = "where ' title ' like '% $keys% '";}//Get Database data//sql Statement $sql = "SELECT * from ' t B_article '. $s;//get resource handle $queryhandle = @mysql_query ($sql) or Die (' SQL execution failed! $totalnum = "SELECT count (*) from ' tb_article '"; $querytotal = mysql_query ($totalnum); $totlnum = Mysql_fetch_ Array ($querytotal);? >| <a href = "update.php?id=<?php echo $result [' id ']?>" > Edit </a> | <a href = "delete.php?id=<?php echo $result [' id ']?>" > Delete </a> |

update.php:

<?php//Introduction of database Connection file require (' conn.php ');//Receive Idif (!empty ($_get[' id ')) {//Receive data $id = $_get[' id '];//sql statement $sql = "Select * from ' tb_article ' WHERE id = ' $id ' limit 1 ';//get resource handle $queryhandle = @mysql_query ($sql) or Die (' SQL execution failed! ');//Get one row of data $result = Mysql_fetch_array ($queryhandle, MYSQL_ASSOC);} Determine if the data is submitted if (!empty ($_post[' Sub ')) {//Receive data $hid = $_post[' hid '); $title = $_post[' title ']; $content = $_post[' content ') ;//determine when to fill in the information if ($title = = "| | $content = =") {echo ' Please fill in the complete information! '; exit ();} The SQL statement $sql = "UPDATE ' tb_article ' SET ' title ' = ' $title ', ' content ' = ' $content ' WHERE id = ' $hid '";//execute and determine whether to perform the successful if (@mysq L_query ($sql) or Die (' SQL execution exception! ') {echo ' <script Language=javascript>alert ("modified successfully!) "); Window.location.replace (" index.php ") </script> ';}}? >

PHP-Small micro-blogging system

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.