PHP:程序无法运行。我不明白这个错误

标签 php html mysql database

我创建了这个 3 页表格。第一个是登记,第二个是进出日期,现在第三个,我试图让用户在超值 parking 、迎宾服务 parking 和灵活 parking 之间进行选择。我在每个按钮旁边创建了一个“选择”按钮,但是,当我单击该按钮时,我检查我的数据库,只有 ID 和用户名得到更新, parking 场的名称不会出现。这是我的代码:

<?php
session_start();
$error=true;
$users=$_SESSION['tsmUserName'];
$Parkingname="";
if (isset($_POST['tsmValueaParking'])){
    $name="value Parking";
    $error=false;
}
if (isset($_POST['tsmMeetGreetService'])){
    $name="Meet and Greet Service Parking";
$error=false;
}
if (isset($_POST['tsmFlexible'])){
    $name="Flexible Parking";
    $error=false;
}
if($error==false){
    require_once("connection.php");
            $my_query="INSERT INTO `parking`(`Id`, `name`, `username`) VALUES (NULL,'$name','$users')";
            $result=mysqli_query($connection,$my_query);
            if($result)
            {
                echo 'thank you';
            }
            else
            {
                echo 'error';
            }
            mysqli_close($connection);
}

?>
<html>
<head></head>
<body>
<form name="picking" id="picking" method="POST" action="">
<table cellpadding="5" border="0" width="100%">
<tr>
            <td align="center">
                <h2> Welcome to Tassimo Online Supermarket </h2>
                <hr>
            </td>
        </tr>
        <tr>
        <td width="30%" align="left">
                    <label for="tsmdate">Value Parking</label></br></br>
                    Our car park is the closest off car park to both terminals. FREE shuttle bus runs every 10 minutes and gets you to the terminals in 3-5 minutes.
                </td>
                </tr>
                <tr>
                <td align="left">
                    <input type="button" name="tsmValueaParking" id="tsmValueaParking" value="pick">
                </td>

                </tr>

                <tr>
                <td width="30%" align="left">
                    <label for="tsmdate">Meet & Greet Service</label></br></br>
                    This is a Meet and Greet Service where you will be met at your departure terminal. Your car will be parked at the secure facility. With this service staff member will meet you at your departure terminal and take your car back to their secure compound. On your return staff member will meet you at the Terminal with your car so you can be on your way home as quickly as possible.
                </td>
                </tr>
            <tr>
                <td align="left">
                    <input type="button" name="tsmMeetGreetService" id="tsmMeetGreetService" value="pick">
                </td>
                </tr>

                <tr>
                <td width="30%" align="left">
                    <label for="tsmdate">Flexible</label></br></br>
                    This car park is located just 500 meters away. The bus service runs every 30 mins. Tickets cost $4.50 one way and are available from the driver.
                </td>
                </tr>
                <tr>
                <td align="left">
                    <input type="button" name="tsmFlexible" id="tsmFlexible" value="pick">
                </td>

                </tr>
            </table>


</form>

最佳答案

问题可能是由于字段类型导致您的表单无法正确提交。改变你的一切:

<input type="button"

<input type="submit"

然后尝试再次提交。我认为如果切换类型提交,您将看到您的 $_POST 正常工作。

顺便说一句,如果您有用户提交的数据,您需要确保谨慎绑定(bind)参数。您想避免 sql 注入(inject)。

关于PHP:程序无法运行。我不明白这个错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41195770/

相关文章:

php - 如何使用 PHP 从 MySQL 数据库中读取图像?

javascript - 使用js offsetHeight获取包含图像的div的高度

检查用户是否被禁止的 PHP 登录脚本问题

mySql 保存了不需要的整数,与输入的不同

php - 为什么数据表默认不能按降序显示数据?

php - 在服务器端验证失败时返回发布数据

php - 如何禁用特定模块的错误 Controller

php - 从外部 php 填充 html 表以允许在悬停在行上时突出显示

javascript - jQuery - 更改单个 DIV 的 CSS

mysql - Configuration failed because libmysqlclient was not found.解决方法是什么?