search

Home  >  Q&A  >  body text

Something went wrong on the message board. I just can’t find where the error is. It’s a headache.

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


学海无涯学海无涯2468 days ago1249

reply all(8)I'll reply

  • 似火年华

    似火年华2018-02-14 16:20:27

    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?

    reply
    0
  • Sven.He

    Sven.He2018-02-12 12:48:15

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

    reply
    0
  • PHP中文网

    PHP中文网2018-02-11 13:56:44

    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.

    reply
    0
  • 学海无涯

    学海无涯2018-02-10 20:14:49

    Can anyone help me check it out?

    reply
    0
  • 徐金龙

    Breakpoint printing is one of the most effective ways to troubleshoot errors.

    徐金龙 · 2018-03-06 09:55:09
  • 韦小宝

    韦小宝2018-02-10 17:28:58

    Is it a direct prompt of failure?

    reply
    0
  • 学海无涯

    Yes Yes

    学海无涯 · 2018-02-10 18:00:28
    韦小宝

    Can you see if you have obtained the data?

    韦小宝 · 2018-02-11 09:09:08
  • Cancelreply