richo89 Posted August 12, 2009 Share Posted August 12, 2009 Hi, I have a page which sends the variable via the URL to the nextpage which in this case is listPlate.php The code to pass the variable is echo "<p><a href='listPlate.php?Customer_ID=$customerid'>Click here to start selling! </a></p>"; On listPlate.php I have the following code: <? //initilize PHP if($_POST['submit']) //If submit is hit { $plate = $_POST[plate]; $keywords = $_POST[keywords]; $category = $_POST[category]; $notes = $_POST[notes]; $cost = $_POST[cost]; $id = $_GET['Customer_ID']; $plate1st = $plate{0}; $plate2nd = $plate{1}; $plate3rd = $plate{3}; $plate4th = $plate{4}; $plate5th = $plate{5}; //Insert the values into the correct database with the right fields //mysql table = purchases $sql=("INSERT INTO prefix (Customer_ID, plate, keywords, category, notes, cost, plate1st, plate2nd, plate3rd, plate4th, plate5th)". "VALUES ('$id','$plate','$keywords','$category','$notes','$cost','$plate1st', '$plate2nd', '$plate3rd', '$plate4th', '$plate5th')"); $result = mysql_query($sql) or die (mysql_error()); echo "<font color='black'>$plate submitted succesfully, $id is customer id</font>"; } ?> However, once I click submit it enters the Customer_ID as blank into my database and for some reason is forgetting what the variable is. When i'm on listPlate.php the URL clearly shows the Customer_ID.. Example.. listPlate.php?Customer_ID=5 Any ideas? Quote Link to comment Share on other sites More sharing options...
trq Posted August 12, 2009 Share Posted August 12, 2009 Assuming listPlate.php is where your form is, what does the forms action look like? Quote Link to comment Share on other sites More sharing options...
taquitosensei Posted August 12, 2009 Share Posted August 12, 2009 you'll have to do a hidden field with your customerid. When you post you're not passing through the URL so you're losing your variable. <input type='hidden' name='customerid' value='".$_GET['Customer_ID']."'> then you'll have $_POST['customerid'] available on the page you posted to. Quote Link to comment Share on other sites More sharing options...
Miko Posted August 12, 2009 Share Posted August 12, 2009 does this work? echo "<p><a href=\"listPlate.php?Customer_ID=$customerid\">Click here to start selling! </a></p>"; Quote Link to comment Share on other sites More sharing options...
richo89 Posted August 12, 2009 Author Share Posted August 12, 2009 you'll have to do a hidden field with your customerid. When you post you're not passing through the URL so you're losing your variable. <input type='hidden' name='customerid' value='".$_GET['Customer_ID']."'> then you'll have $_POST['customerid'] available on the page you posted to. I have the following: <form action="listPlate.php" method="POST"> <input type='hidden' name='customerid' value='".$_GET['Customer_ID']."'> However, when I echo whats been submitted I get the following: Z2 ZZZ submitted succesfully, \".$_GET[ is customer id Quote Link to comment Share on other sites More sharing options...
trq Posted August 12, 2009 Share Posted August 12, 2009 You need to explain to us what pages are where within the process. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.