基于PHP与MYSQL的动态网站开发实例.docxVIP

  • 2
  • 0
  • 约1.43千字
  • 约 3页
  • 2026-04-07 发布于云南
  • 举报

基于PHP与MYSQL的动态网站开发实例

php

?php

require_oncecheck_login.php;

require_oncedb_connect.php;

//处理表单提交

if($_SERVER[REQUEST_METHOD]===POST){

$title=trim($_POST[title]);

$content=trim($_POST[content]);

$author_id=$_SESSION[user_id];

//简单验证

if(empty($title)||empty($content)){

$error=标题和内容不能为空!;

}else{

try{

$stmt=$pdo-prepare(INSERTINTOarticles(title,content,author_id)VALUES(:title,:content,:author_id));

$stmt-bindParam(:title,$title);

$stmt-bindParam(:content,$content);

$stmt-bindParam(:author_id,$author_id);

$stmt-execute();

//添加成功,重定向到文章列表

header(Location:dashboa

文档评论(0)

1亿VIP精品文档

相关文档