PHP开发企业网站教程之添加关于我们信息
看下面的代码:
<!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>表单提交到 addabout.php 页面 进行处理
代码如下:
<?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>";
}
}
?>获取表单的信息,然后添加到数据库
neue Datei
<!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>
Vorschau
Clear
- Kursempfehlungen
- Kursunterlagen herunterladen
Die Kursunterlagen stehen derzeit nicht zum Download zur Verfügung. Die Mitarbeiter organisieren es derzeit. Bitte schenken Sie diesem Kurs in Zukunft mehr Aufmerksamkeit
Auch Studierende, die diesen Kurs gesehen haben, lernen
Lassen Sie uns kurz über die Gründung eines Unternehmens in PHP sprechen
Kurze Einführung in die Web-Frontend-Entwicklung
Umfangreiche, praktische Tianlongbabu-Entwicklung eines Mini-Version-MVC-Frameworks, das die Enzyklopädie-Website mit peinlichen Dingen imitiert
Erste Schritte mit der praktischen PHP-Entwicklung: Schnelle PHP-Erstellung [Small Business Forum]
Anmeldebestätigung und klassisches Message Board
Wissenssammlung über Computernetzwerke
Schnellstart-Node.JS-Vollversion
Der Frontend-Kurs, der Sie am besten versteht: HTML5/CSS3/ES6/NPM/Vue/...[Original]
Schreiben Sie Ihr eigenes PHP-MVC-Framework (40 Kapitel ausführlich/große Details/Muss gelesen werden, damit Neulinge vorankommen)
















