我有一些問題試圖將$ _GET變量發佈到表中。
這裏是我的腳本:
include 'connect.php';
if(isset($_POST['client_name'])) {
$_GET['list']; //these are variables passed through from another page and I want these to post in the same table this page is suppose to post in.
$_GET['list_id'];
$Cname = $_POST['client_name'];
$Cnumber = $_POST['client_number'];
$listid = $_POST['list_id'];
$listname = $_POST['list'];
if(!empty($Cname) && !empty($Cnumber)){
$query = "INSERT INTO clients (id, client_name, client_number, list_name, date_registered, list_id) VALUES ('$userid','$Cname', '$Cnumber', '$listname', now(), '$listid')";
mysql_query($query);
echo '<br />
<br />
You successfully added a new clients to your list <a href="http://somewebsite.com/clients.php">View Update</a>';
mysql_close();
}
else {
echo '<script type="text/javascript">alert("Both fields are required");</script>';
}
每當我運行該腳本一切,但LISTNAME和LIST_ID被張貼在數據庫表中。 我嘗試將獲取變量分配給新變量,如
$ listNAME = $ _GET ['id'];
,但即便如此我還是最終在我的桌子空字段
我甚至嘗試使用$ _GET變量在MySQL的INSERT查詢,仍然沒有運氣
誰能幫助我,並給我一些建議,說明腳本運行時我能做些什麼來解決空白字段。
<form action="addclient.php" method="POST">
Name of Client: <input type="text" name="client_name">
Client's Number: <input type="text" name="client_number" placeholder="1-876-xxx-xxx">
<input type="submit" >
</form>
當你打印出get變量時,你看到了什麼? –
@MrD我看到通過URL – mattchambers
傳遞的變量的信息,您的列設置爲正確的數據類型? varchar或文本或>>? –