yuchao19950412

大体思路:
根据查询数据库,打印一张表,当点击添加按钮,跳转至新闻页面进行添加,添加完成,经过新闻添加页面的处理,获取提交的值,通过MySQL语句,进行添加。

新闻页面:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>无标题文档</title> <style> *{ margin-top:10px; padding:0px; } </style> </head> <body> <h3>发布新闻</h3> <form method="post" action="xwchuli.php"> <div>标题:<input type="text" name="title" style="width:350px;"/></div> <div class="b">作者:<input type="text" name="author" /></div> <div class="c">来源:<input type="text" name="source" /></div> <div>内容:<textarea cols="50" rows="5" name="content"></textarea></div> <div>时间:<input type="text" name="time" /></div> <div style="margin-left:80px;"><input type="submit" value="提交" /><input type="submit" value="查看" /></div> </form> </body> </html>


新闻添加处理页面:
<?php $title=$_POST["title"]; //获取form表单提交的name值 POST数组接受 $author=$_POST["author"]; $source=$_POST["source"]; $content=$_POST["content"]; $time=$_POST["time"]; $db=new MySQLi("localhost","root","","xinwen"); !mysqli_connect_error() or die("连接失败!"); $sql="insert into news values(\'\',\'{$title}\',\'{$author}\',\'{$source}\',\'{$content}\',\'{$time}\')"; $result=$db->query($sql); if($result) { header("location:zhuye.php"); } else { echo"失败"; } ?>

  

  

分类:

技术点:

相关文章:

  • 2021-05-27
  • 2022-12-23
  • 2021-10-26
  • 2021-10-19
  • 2019-12-17
  • 2021-10-01
  • 2021-12-22
  • 2021-07-12
猜你喜欢
  • 2022-01-18
  • 2021-10-20
  • 2021-12-28
  • 2021-09-17
  • 2022-12-23
  • 2021-09-30
相关资源
相似解决方案