Php uses smarty for simple message system, detailed steps are simple, smarty message system
The message is an example of the previous use of php. Now we use the smarty template for the message.
This is probably the case.
Click Publish information
Then fill in the content. After the message is sent, the table will be returned, and the written content will appear in the table.
The data in the database is as follows:
Create two files first. Php and html
Log on to the console and log on with the previously created login.
Php
First introduce the entry file, then query the database, call the SQL statement, and then display the page
<?phpinclude("../init.inc.php");include("../DBDA.php");$db = new DBDA();$sql =" select * from xinxi";$attr = $db->Query($sql);$smarty->assign("liuyan",$attr);$smarty->display("liuyan.html");
Html
Write the table format and traverse the database data.
The Code is as follows:
<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
This is how it works.
Go back to the fabu. php page
PHP File
<?phpinclude("../init.inc.php");$smarty->display("fabu.html");
Because the Publishing Page does not need to use a database or anything, you only need to display the html file, so there are two sentences of code.
Html file
<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <Br/>
<Div> <input type = "submit" value = "send"/> <input type = "reset" value = "reset"/> </div> </form> </body>
This page is displayed.
The following is the release processing page, that is, fabuchuli. php.
This page is for processing php-only pages and does not need to be seen by users. Therefore, we only need to make a php file here.
Before doing this, we need to add something to the login page.
As follows:
This is its processing page. Enable the session and store the uid in the session.
And then use it on the release processing page.
The fabuchuli. php code is as follows:
<? Phpsession_start (); $ uid = $ _ SESSION ["uid"]; include (".. /init. inc. php "); include (".. /DBDA. php "); $ db = new DBDA (); $ SQL =" select * from users where uid = '{$ uid }'"; $ attr = $ db-> Query ($ SQL);?> <? Php $ fsr = "{$ attr [0] [0]}"; $ fssj = date ("Y-m-d", time ()); $ jsr = $ _ POST ["jsr"]; $ xxnr = $ _ POST ["xxnr"]; // create a connection object $ db = new MySQLi ("localhost ", "root", "726", "text11"); // write an SQL statement $ SQL = "insert into xinxi values ('', '{$ fsr }', '{$ fssj}', '{$ jsr}', '{$ xxnr}') "; // execute $ r = $ db-> query ($ SQL ); if ($ r) {header ("location: liuyan. php ") ;}else {echo" failed to add ";}?>
This is probably done. The deletion of the information system is not done. In the previous blogs, you only need to add a processing page.
Run the command again to check whether the sender will be removed after the last release is completed.
Run
Enter the user name and password, and then click Login
After login, all the xinxi data in the database will be displayed.
Click exit to return to the logon page.
Click Publish information
Enter content in the text box
Click send to return to the home page.
The content you just wrote will appear in the table.
Running successful