search

Home  >  Q&A  >  body text

Message board message failed

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

圆子圆子2037 days ago1611

reply all(2)I'll reply

  • 路过

    路过2019-04-28 11:53:08

    No connection to mysql, no database selected

    reply
    0
  • 圆子

    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?

    圆子 · 2019-04-28 11:55:14
  • Cancelreply