Add page: Explanation: Only pay attention to the operation here, and there is no time for the artist of the interface. I hope everyone understands ...
List page:
Modify page:
SQL required in the project:
Copy code The code is as follows:
create database form;
use form;
CREATE TABLE `message` ( `id` tinyint(1) NOT NULL auto_increment, `user` varchar(25) NOT NULL, `title` varchar(50) NOT NULL, `content` tinytext NOT NULL, `lastdate` date NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET= gbk AUTO_INCREMENT=1;
conn.php
Copy code The code is as follows:
$conn = @ mysql_connect("localhost", "root", "") or die("Database link error"); mysql_select_db("form", $conn); mysql_query("set names 'gbk'"); ?>
add.php
Copy code The code is as follows:
include 'conn.php'; if($_POST['submit']){ $sql="INSERT INTO message(id,user,title,content,lastdate) VALUES (NULL, '$_POST[user]', '$_POST[title]', '$_POST[content]', now())"; mysql_query ($sql);
//Page jump, implemented by javascript $url = "list.php"; echo ""; } ?> < ;script type="text/javascript"> function checkPost(){
if(addForm.user.value==""){ alert("Please enter username") ; addForm.user.focus(); return false; } if(addForm.title.value.length<5){ alert("The title cannot be less than 5 characters"); addForm.title.focus(); return false; } }
include 'conn.php'; $id = $_GET['id']; $query="delete from message where id=".$id; mysql_query($query); ?> //页面跳转,实现方式为javascript $url = "list.php"; echo ""; ?>
preEdit.php
复制代码 代码如下:
include 'conn.php'; $id=$_GET[id]; $query="SELECT * FROM message WHERE id =".$id; $result=mysql_query($query); while ($rs=mysql_fetch_array($result)){ ?>
postEdit.php
复制代码 代码如下:
include 'conn.php'; $query="update message set user='$_POST[user]',title='$_POST[title]',content='$_POST[content]' where id='$_POST[id]'"; mysql_query($query); ?> //页面跳转,实现方式为javascript $url = "list.php"; echo ""; ?>
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn