PHP在表字段中发布$ _GET变量

I'm having some problems trying to post $_GET variables into a table.

Here is my script:

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>';
        }

Whenever I run the script everything else but the listname and list_id is posted in the database table. I tried assigning the get variables to new variable such as

$listNAME = $_GET['id'];

but even with that I still end up with empty fields in my table

I even tried to use the $_GET variable in the mysql INSERT query and still no luck

Can anyone help me out and give me some advice as to what I can do to solve the empty fields when the script runs.

<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>

I say it only to notice .

Please use PDO or mysqli


if you are calling your addclient.php like

http://localhost/addclient.php?list_id=100&list=mylistname

than you must catch both variables in addclient.php

if (isset($_GET['list_id'])) {

 $listid = $_GET['list_id'];
 $listname = $_GET['list'];

}

and your form

<form action="addclient.php" method="POST">
    <input type="hidden" name="list_id" value="$listid">
    <input type="hidden" name="list" value="$listname">
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>

and after submit

if(isset($_POST['client_name'])) {

$Cname = $_POST['client_name'];
$Cnumber = $_POST['client_number'];
$listid = $_POST['list_id'];
$listname = $_POST['list'];
....
}

and in your insert

VALUES ('$userid','$Cname', '$Cnumber', '$listname', now(), '$listid')

$listid without quotes it's a int(11) .

VALUES ('$userid','$Cname', '$Cnumber', '$listname', now(), $listid)

You say you have $_GET variables, but you are trying to retrieve them as $_POST variables:

$listid = $_POST['list_id'];
$listname = $_POST['list'];

Isn't it the issue? You could also try this to see what's comming in both arrays:

print_r($_GET);
print_r($_POST);

Alternatively, you could use $_REQUEST as it receives either $_GET or $_POST variables.