0
我無法將單選按鈕值傳遞給函數。這些值正在生成。我在頁面上同時回顯$ company_id和$ _POST ['package'],並且都正確回顯。下面,我提供了tecnoDB函數select_service的代碼,我嘗試實例化以及單選按鈕所在頁面的實際代碼。我沒有在代碼中使用任何JavaScript。單選按鈕值未傳遞給php函數
這裏是頁面,其中單選按鈕:
<?php
session_start();
if (!array_key_exists("user", $_SESSION)) {
header('Location: index.php');
exit;
}
require_once("Includes/tecnoDB.php");
$company_id = tecnoDB::getInstance()->get_company_id_by_name($_SESSION['user']);
if ($_SERVER["REQUEST_METHOD"] == [$_POST]){
if (array_key_exists("contratar", $_POST)){
require_once("Includes/tecnoDB.php");
tecnoDB::getInstance()->select_service($company_id, $_POST['package']);
header("Location: companyControlPanel.php");
}
}
?>
<form name="selection" action="" method="POST">
<ul>
<li>Recruiter Lite <input type="radio" name="package" value="1" /></li>
<li>Recruiter Plus <input type="radio" name="package" value="2" /></li>
<li>Premium <input type="radio" name="package" value="3" /></li>
</ul>
<input type="submit" name="contratar" value="Contratar Servicio" />
</form>
這裏,我試圖實例
public function select_service($company_id, $package){
$company_id = $this->real_escape_string($company_id);
$package = $this->real_escape_string($package);
$this->query("UPDATE company SET service = '" . $package . "' WHERE id = '" . $company_id . "'");
}
真的不知道爲什麼功能不被實例化select_service功能當參數存在時。請幫忙。
與您所說的完美搭配。我很感激。我知道我必須錯過簡單的事情。新鮮的眼睛總是工作。 – MScranton