Message board message failed
圆子
圆子 2019-04-26 19:13:08
0
2
1565

This is the code for the message section of the page. The problem is that the account is logged in, and then the message title and content are written, but the display fails after submission. I don’t know what went wrong. I hope you can teach me. Thank you. !

<?php
require("header.php");
if($_SESSION[username]=="")
  {
    echo "<script>alert('请先登录');history.back();</script>";
exit;
  }
if($act=="save")
{
if($title=="" || $content=="")
{
echo "<script>alert('留言标题,内容,不能为空');history.back();</script>";
exit;
}
$sql="insert into liuyan (title,content,userid) values ('$title','$content','$_SESSION[username]')";
$res=mysql_query($sql);
if($res)
{
echo "<script>alert('成功');location.href='guest.php';</script>";
exit;
}
else
exit("失败了");
}
?>

1556277045695565.jpgThe above is the content of the message data table

圆子
圆子

reply all(1)
路过

No connection to mysql, no database selected

  • reply How to connect to the database and select the data table? Sorry, I'm a novice, can you tell me exactly what I should do?
    圆子 author 2019-04-28 11:55:14
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!