我创建了这3页表格。第一个是注册,第二个是进入和退出日期,现在是第三个,我试图让用户在价值停车,见面和迎接服务停车和灵活停车之间做出选择。我在每一个旁边创建了一个“选择”按钮,然而,当我点击按钮时,我检查我的数据库,只有id和用户名更新,停车名称没有出现..这里是我的代码:
<?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>
答案 0 :(得分:0)
问题可能是由于您的表单由于字段类型而无法正确提交。改变你的全部:
<input type="button"
到
<input type="submit"
然后尝试再次提交。我认为如果要提交切换类型,您会看到$_POST
正常工作。
另外,如果您有用户提交的数据,则需要确保绑定参数时要小心。你想避免sql注入。