我在尝试将 $_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 之外的所有其他内容都会发布在数据库表中。我尝试将 get 变量分配给新变量,例如
$listNAME = $_GET['id'];
但即便如此,我的表中仍然有空字段
我什至尝试在 mysql INSERT 查询中使用 $_GET 变量,但仍然没有运气
任何人都可以帮助我并就脚本运行时我可以做些什么来解决空字段给我一些建议。
<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>