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 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么