2015-11-30 105 views
0

所以我的問題是,我無法使用單選按鈕將數據插入選定的表。單選按鈕用於告訴我們我們需要訪問哪個表並添加數據。我認爲我說得對,但沒有奏效。這是我的。任何形式的幫助將不勝感激。使用單選按鈕插入功能

<h1 align="center">Event</h1> 
<h1 align="center"><a href="stroage.html" target="new">Storage</a></h1> 
<form action="set_event.php" method="post"> 
<p> 
<p> 
<input type="submit" name="submit" value="Set Items"> 
</p> 
<p> 
<br> 
<label> 
<input type="radio" name="storage" value="concourse_stairs_s" id="s1"> 
Concourse Stairs</label> 
<br> 
<label> 
<input type="radio" name="storage" value="bat_cave_s" id="s2"> 
Bat Cave</label> 
<br> 
<label> 
<input type="radio" name="storage" value="fireside_s" id="s3"> 
Fireside Storage</label> 
<br> 
</p> 
<?php 
if ($_SERVER['REQUEST_METHOD'] == 'POST') { 

require ('mysqli_connect.php'); // Connect to the db. 

$errors = array(); // Initialize an error array. 

} 


if (isset($_REQUEST['bat_cave_s'])) 
{ 
$q = "INSERT INTO bat_cave_s (item_name, check_in) VALUES ('test', NOW())";  
$r = @mysqli_query ($dbc, $q); // Run the query. 
} 
else if(isset($_REQUEST['concourse_stairs_s'])) 
{ 
$q = "INTO concourse_stairs_s (item_name, check_in) VALUES ('test', NOW())";  
$r = @mysqli_query ($dbc, $q); // Run the query. 
} 
else if(isset($_REQUEST['fireside_s'])) 
{ 
$q = "INSERT INTO fireside_s (item_name, check_in) VALUES ('test', NOW())";  
$r = @mysqli_query ($dbc, $q); // Run the query. 
} 
NOW())"; 

回答

0

您的PHP正在檢查錯誤的東西。

您需要檢查$_REQUEST['storage']的值。

if($_REQUEST['storage'] == 'bat_cave_s') {