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>