Something went wrong on the message board. I just can't find where the error is. It's a headache.
学海无涯
学海无涯 2018-02-10 17:20:22
0
8
1263

add.php file content

<?php
//Import the connection database file
include ('conn.php');
//Check whether the user Submit button
if(isset($_POST['submit'])){
                                                                                   - $title=$_POST['title'];
$content=$_POST['content'];
$sql="insert into message(id,user,title,content,lastdate)values('' ,'$user','$title','$content',now())";
mysqli_query($conn,$sql);
// echo "<script>alert('Added successfully ');history.go(-1)</script>";
echo"<script>alert('Message successful');location.href='liu.html'</script>";
}else{
echo "Failed";
}
?>

##liu.html content

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title>第一个MYSQL查询留言本</title>
<script type="text/javascript" src="http://www.francescomalagrino.com/BootstrapPageGenerator/3/js/jquery-2.0.0.min.js"></script>
<script type="text/javascript" src="http://www.francescomalagrino.com/BootstrapPageGenerator/3/js/jquery-ui"></script>
<link href="http://www.francescomalagrino.com/BootstrapPageGenerator/3/css/bootstrap-combined.min.css" rel="stylesheet" media="screen">
<script type="text/javascript" src="http://www.francescomalagrino.com/BootstrapPageGenerator/3/js/bootstrap.min.js"></script>
         <?php include ("add.php")?>
    </head>
    <body>
        <?php include ("add.php")?>
        <div class="container-fluid">
    <div class="row-fluid">
        <div class="span12">
            <div class="page-header">
                <h1>
                    第一个MYSQL查询留言本 <small>V1.0</small>
                </h1>
            </div>:                                                                          A visual layout template, you can click on the text in the template to modify, or click on the pop-up edit box to modify the rich text. Drag the block to sort. ;
                                                                                                                                                                                                                ;
            <table class="table table-bordered">
                <thead>
                    <tr>
                        <th>
                            ID
                        </th>
                        <th>
                            名字
                        </th>
                        <th>
                            标题
                        </th>
                        <th>
                            内容
                        </th>
                    </tr>
                </thead>
                <tbody>
                    <tr class="success">
                        <td>
                            ID
                        </td>
                        <td>
                            TB - Monthly
                        </td>
                        <td>
                            01/04/2012
                        </td>
                        <td>
                            Approved
                        </td>
                    </tr>

                </tbody>
            </table>
            <form action="add.php" method="post">
                <fieldset>
                     <legend>表单项</legend>
                     <label>名字</label><input type="text" name="user" required/>
                     <label>标题</label><input type="text" name="title" required/>  
                     <label>留言内容</label><textarea name="content" rows="5" cols="30"></textarea>
                     <hr>
<button type="submit" class="btn" name="submith">Submit</button>
                                                                                             
</div>
</div>
</body>
</html>





Question: That’s right, I didn’t feel like I had gone through the submission yet, but then I got to else


学海无涯
学海无涯

reply all(5)
似火年华

Are you sure your sql statement is correct $sql="insert into message(id,user,title,content,lastdate)values('','$user','$title','$content' ,now())";

values(" Is this wrong?

Sven.He

You will definitely come to Else. Do not submit, $ _ Post ['Submit'] must have no content.

猪哥

Did the addition fail? ? ? ? Look at the SQL statement. Single quotes do not parse variables. Others cannot be seen from the code for the time being.

学海无涯

Can anyone help me check it out?

  • reply Breakpoint printing is one of the most effective ways to troubleshoot errors.
    徐金龙 author 2018-03-06 09:55:09
lge

Is it a direct prompt of failure?

  • reply Yes Yes
    学海无涯 author 2018-02-10 18:00:28
  • reply Can you see if you have obtained the data?
    韦小宝 author 2018-02-11 09:09:08
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template