PHP Development Enterprise Website Tutorial: Add About Us Information
Look at the code below:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>添加信息</title>
<style type="text/css">
.ipt{width:180px;height:30px;border-radius:5px;
outline:none;border:1px solid #eee;box-sizing:border-box;padding-left:15px;}
.txt{width:250px;height:200px;}
.sub{width:50px;height:20px;border:1px solid #eee;background:#eee;color:#ff7575;}
</style>
</head>
<body>
<form method="post" action="addabout.php">
标题:<input type="text" name="title" class="ipt">
</br></br>
内容:<textarea cols="50" rows="5" name="content" class="txt"></textarea></br></br>
<input type="submit" value="添加" class="sub">
</form>
</body>
</html>The form is submitted to the addabout.php page for processing
The code is as follows:
<?php
require_once('conn.php');
//htmlspecialchars() 过滤html
$title = htmlspecialchars($_POST['title']);
$content = htmlspecialchars($_POST['content']);
if(empty($title)){
echo "请输入标题";
}else if(empty($content)){
echo "请输入内容";
}else{
$sql = "insert into `about`(title,content) values('$title','$content')";
$res = mysql_query($sql);
if($res){
echo "<script>alert('添加信息成功');location.href='about.php';</script>";
}else{
echo "<script>alert('添加信息失败');history.go(-1);</script>";
}
}
?>Get the form information and then add it to the database
new file
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>添加信息</title>
<style type="text/css">
.ipt{width:180px;height:30px;border-radius:5px;
outline:none;border:1px solid #eee;box-sizing:border-box;padding-left:15px;}
.txt{width:250px;height:200px;}
.sub{width:50px;height:20px;border:1px solid #eee;background:#eee;color:#ff7575;}
</style>
</head>
<body>
<form method="post" action="addabout.php">
标题:<input type="text" name="title" class="ipt">
</br></br>
内容:<textarea cols="50" rows="5" name="content" class="txt"></textarea></br></br>
<input type="submit" value="添加" class="sub">
</form>
</body>
</html>
Preview
Clear
- Course Recommendations
- Courseware download
The courseware is not available for download at the moment. The staff is currently organizing it. Please pay more attention to this course in the future~
Students who have watched this course are also learning
Let's briefly talk about starting a business in PHP
Quick introduction to web front-end development
Large-scale practical Tianlongbabu development of Mini version MVC framework imitating the encyclopedia website of embarrassing things
Getting Started with PHP Practical Development: PHP Quick Creation [Small Business Forum]
Login verification and classic message board
Computer network knowledge collection
Quick Start Node.JS Full Version
The front-end course that understands you best: HTML5/CSS3/ES6/NPM/Vue/...[Original]
Write your own PHP MVC framework (40 chapters in depth/big details/must read for newbies to advance)
















