dongren2128 2019-07-23 05:28
浏览 53
已采纳

我不明白为什么这个HTML页面没有进入PHP页面[关闭]

I have this HTML page that is supposed to be able to access 2 different PHP pages that each performs SQL. This first part of the HTML works and goes to the first PHP page but the second one isn't going. When I click on the button, the HTML page doesn't do anything. Here is my HTML code:

<html>
<body>
    <form action="insertartist.php" method="post">
        <h3>Artist Insertion:</h3>
        First Name: <input type="text" name= "fname" placeholder="First Name"><br><br>
        Last Name: <input type= "text" name= "lname" placeholder="Last Name"><br><br>
        DOB: <input type= "text" name= "dob" placeholder="YYYY-MM-DD"><br><br>
        Hometown: <input type= "text" name= "hometown" placeholder="Hometown"><br><br>
        Gender: <input type= "text" name= "gender" placeholder="Gender"><br><br>
        <input type="submit" value="Insert Artist"><br>
    </form>

    <form action="selectartist.php" method="post">
        <h3>Select Artist Table:</h3>
        <input type="submit" value="Select Artist Table"
    </form>
</body>

Here is my PHP code for the second PHP page that isn't working: I removed the connection info for the database. I know it's correct because it is the same as the first PHP page which is working. It also doesn't give me any errors or do anything at all, I click the "Select Artist Table" button on the HTML page and it just sits there and nothing happens. I am very confused because the first page is working and is setup the same way.

<?php
$conn = mysqli_connect("???", "???", 
"???", "???");

if (!$conn) {
    die("Connection to SQL failed: " . mysqli_connect_error());
}
else {
    echo "Established Database Connection: ";
}

$sql = "SELECT * FROM artist;"
$result = mysqli_query($conn, $sql);
$num_rows = mysqli_num_rows($result);

if ($result->num_rows > 0) {
    echo "<table>";
    echo "<tr><th>Artist ID</th><th>First Name</th><th>Last Name</th> 
    <th>DOB</th><th>Hometown</th><th>Gender</th></tr>";

while($row = $result->fetch_assoc()) {
    echo "<tr><td>".$row["aid"]."</td><td>".$row["fname"]."</td> 
   <td>".$row["lname"]."</td><td>".$row["dob"]."</td> 
   <td>".$row["hometown"]." 
   </td><td>".$row["gender"]."</td></tr>";
}
echo "</table>";
} else {
    echo "0 Results";
}

echo "$num_rows Rows
";

mysqli_close($conn);
?>
  • 写回答

1条回答 默认 最新

  • douxugu5836 2019-07-23 05:32
    关注

    Close input tag in second form

     <form action="selectartist.php" method="post">
            <h3>Select Artist Table:</h3>
            <input type="submit" value="Select Artist Table"/>
        </form>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器