dark_destroyer Posted August 29, 2012 Share Posted August 29, 2012 Hi All, I am a realtively novice PHP/MySQL developer. I have been baking my noodle for days now on this. I have a login page that takes a username/password, queries it against a MySQL DB and returns a list of users. I store the Username/Password as a variable, and then use it to pass as a parameter in various queries. One of the functions of the site is that when a user logs in, he/she is presented with a list of associated users in their company. They are then able to edit the details for that user. This all works fine. However, I am using a Form to Submit the data to MySQL, once the update has happened i have a simple set of links at the bottom of the page to navigate the user back to the user list page. <html> <head> <title>PeopleSafe</title> </head> <body> <ul id="tabs1"> <li><a href="contacts_list.html">Login Page</a></li> <li><a href="return_contacts_list.php?AccountID=<?php echo $AccountID;?>">User List</a></li> <li><a href="user_details.php?ContactID=<?php echo $ContactID;?>&AccountID=<?php echo $AccountID;?>">User Details</a></li> <li><a href="escalation_details.php?ContactID=<?php echo $ContactID;?>&AccountID=<?php echo $AccountID;?>">Escalation Details</a></li> <li><a href="pool_users.php?ContactID=<?php echo $ContactID;?>&AccountID=<?php echo $AccountID;?>">Pool Users</a></li> </ul> <?php $_REQUEST["Pool01Name"]; $_REQUEST["Pool02Name"]; $_REQUEST["Pool03Name"]; $_REQUEST["Pool04Name"]; $_REQUEST["Pool05Name"]; $_REQUEST["Pool06Name"]; $_REQUEST["Pool07Name"]; $_REQUEST["Pool08Name"]; $_REQUEST["Pool09Name"]; $_REQUEST["Pool10Name"]; $_REQUEST["Pool11Name"]; $_REQUEST["Pool12Name"]; $_REQUEST["Pool13Name"]; $_REQUEST["Pool14Name"]; $_REQUEST["Pool15Name"]; $_REQUEST["Pool16Name"]; $_REQUEST["Pool17Name"]; $_REQUEST["Pool18Name"]; $_REQUEST["Pool19Name"]; $_REQUEST["Pool20Name"]; $_REQUEST["Pool01Number"]; $_REQUEST["Pool02Number"]; $_REQUEST["Pool03Number"]; $_REQUEST["Pool04Number"]; $_REQUEST["Pool05Number"]; $_REQUEST["Pool06Number"]; $_REQUEST["Pool07Number"]; $_REQUEST["Pool08Number"]; $_REQUEST["Pool09Number"]; $_REQUEST["Pool10Number"]; $_REQUEST["Pool11Number"]; $_REQUEST["Pool12Number"]; $_REQUEST["Pool13Number"]; $_REQUEST["Pool14Number"]; $_REQUEST["Pool15Number"]; $_REQUEST["Pool16Number"]; $_REQUEST["Pool17Number"]; $_REQUEST["Pool18Number"]; $_REQUEST["Pool19Number"]; $_REQUEST["Pool20Number"]; $_REQUEST["Pool01DOB"]; $_REQUEST["Pool02DOB"]; $_REQUEST["Pool03DOB"]; $_REQUEST["Pool04DOB"]; $_REQUEST["Pool05DOB"]; $_REQUEST["Pool06DOB"]; $_REQUEST["Pool07DOB"]; $_REQUEST["Pool08DOB"]; $_REQUEST["Pool09DOB"]; $_REQUEST["Pool10DOB"]; $_REQUEST["Pool11DOB"]; $_REQUEST["Pool12DOB"]; $_REQUEST["Pool13DOB"]; $_REQUEST["Pool14DOB"]; $_REQUEST["Pool15DOB"]; $_REQUEST["Pool16DOB"]; $_REQUEST["Pool17DOB"]; $_REQUEST["Pool18DOB"]; $_REQUEST["Pool19DOB"]; $_REQUEST["Pool20DOB"]; $_REQUEST["ContactID"]; $_REQUEST["AccountID"]; $_REQUEST["FirstName"]; $_REQUEST["LastName"]; $_FirstName = $_REQUEST["FirstName"]; $_LastName = $_REQUEST["LastName"]; $_AccountID = $_REQUEST["AccountID"]; $_ContactID = $_REQUEST["ContactID"]; $_Pool01Name = $_REQUEST["Pool01Name"]; $_Pool02Name = $_REQUEST["Pool02Name"]; $_Pool03Name = $_REQUEST["Pool03Name"]; $_Pool04Name = $_REQUEST["Pool04Name"]; $_Pool05Name = $_REQUEST["Pool05Name"]; $_Pool06Name = $_REQUEST["Pool06Name"]; $_Pool07Name = $_REQUEST["Pool07Name"]; $_Pool08Name = $_REQUEST["Pool08Name"]; $_Pool09Name = $_REQUEST["Pool09Name"]; $_Pool10Name = $_REQUEST["Pool10Name"]; $_Pool11Name = $_REQUEST["Pool11Name"]; $_Pool12Name = $_REQUEST["Pool12Name"]; $_Pool13Name = $_REQUEST["Pool13Name"]; $_Pool14Name = $_REQUEST["Pool14Name"]; $_Pool15Name = $_REQUEST["Pool15Name"]; $_Pool16Name = $_REQUEST["Pool16Name"]; $_Pool17Name = $_REQUEST["Pool17Name"]; $_Pool18Name = $_REQUEST["Pool18Name"]; $_Pool19Name = $_REQUEST["Pool19Name"]; $_Pool20Name = $_REQUEST["Pool20Name"]; $_Pool01Number = $_REQUEST["Pool01Number"]; $_Pool02Number = $_REQUEST["Pool02Number"]; $_Pool03Number = $_REQUEST["Pool03Number"]; $_Pool04Number = $_REQUEST["Pool04Number"]; $_Pool05Number = $_REQUEST["Pool05Number"]; $_Pool06Number = $_REQUEST["Pool06Number"]; $_Pool07Number = $_REQUEST["Pool07Number"]; $_Pool08Number = $_REQUEST["Pool08Number"]; $_Pool09Number = $_REQUEST["Pool09Number"]; $_Pool10Number = $_REQUEST["Pool10Number"]; $_Pool11Number = $_REQUEST["Pool11Number"]; $_Pool12Number = $_REQUEST["Pool12Number"]; $_Pool13Number = $_REQUEST["Pool13Number"]; $_Pool14Number = $_REQUEST["Pool14Number"]; $_Pool15Number = $_REQUEST["Pool15Number"]; $_Pool16Number = $_REQUEST["Pool16Number"]; $_Pool17Number = $_REQUEST["Pool17Number"]; $_Pool18Number = $_REQUEST["Pool18Number"]; $_Pool19Number = $_REQUEST["Pool19Number"]; $_Pool20Number = $_REQUEST["Pool20Number"]; $_Pool01DOB = $_REQUEST["Pool01DOB"]; $_Pool02DOB = $_REQUEST["Pool02DOB"]; $_Pool03DOB = $_REQUEST["Pool03DOB"]; $_Pool04DOB = $_REQUEST["Pool04DOB"]; $_Pool05DOB = $_REQUEST["Pool05DOB"]; $_Pool06DOB = $_REQUEST["Pool06DOB"]; $_Pool07DOB = $_REQUEST["Pool07DOB"]; $_Pool08DOB = $_REQUEST["Pool08DOB"]; $_Pool09DOB = $_REQUEST["Pool09DOB"]; $_Pool10DOB = $_REQUEST["Pool10DOB"]; $_Pool11DOB = $_REQUEST["Pool11DOB"]; $_Pool12DOB = $_REQUEST["Pool12DOB"]; $_Pool13DOB = $_REQUEST["Pool13DOB"]; $_Pool14DOB = $_REQUEST["Pool14DOB"]; $_Pool15DOB = $_REQUEST["Pool15DOB"]; $_Pool16DOB = $_REQUEST["Pool16DOB"]; $_Pool17DOB = $_REQUEST["Pool17DOB"]; $_Pool18DOB = $_REQUEST["Pool18DOB"]; $_Pool19DOB = $_REQUEST["Pool19DOB"]; $_Pool20DOB = $_REQUEST["Pool20DOB"]; $link = mysql_connect("localhost", "username","password") or die(mysql_error()); if (!$link) { die('Could not connect: ' . mysql_error()); } mysql_select_db("peoplesafe") or die(mysql_error()); $sql="UPDATE contacts SET Pool01Name='$_Pool01Name', Pool02Name='$_Pool02Name', Pool03Name='$_Pool03Name', Pool04Name='$_Pool04Name', Pool05Name='$_Pool05Name', Pool06Name='$_Pool06Name', Pool07Name='$_Pool07Name', Pool08Name='$_Pool08Name', Pool09Name='$_Pool09Name', Pool10Name='$_Pool10Name', Pool11Name='$_Pool11Name', Pool12Name='$_Pool12Name', Pool13Name='$_Pool13Name', Pool14Name='$_Pool14Name', Pool15Name='$_Pool15Name', Pool16Name='$_Pool16Name', Pool17Name='$_Pool17Name', Pool18Name='$_Pool18Name', Pool19Name='$_Pool19Name', Pool20Name='$_Pool20Name', Pool01Number='$_Pool01Number', Pool02Number='$_Pool02Number', Pool03Number='$_Pool03Number', Pool04Number='$_Pool04Number', Pool05Number='$_Pool05Number', Pool06Number='$_Pool06Number', Pool07Number='$_Pool07Number', Pool08Number='$_Pool08Number', Pool09Number='$_Pool09Number', Pool10Number='$_Pool10Number', Pool11Number='$_Pool11Number', Pool12Number='$_Pool12Number', Pool13Number='$_Pool13Number', Pool14Number='$_Pool14Number', Pool15Number='$_Pool15Number', Pool16Number='$_Pool16Number', Pool17Number='$_Pool17Number', Pool18Number='$_Pool18Number', Pool19Number='$_Pool19Number', Pool20Number='$_Pool20Number', Pool01DOB='$_Pool01DOB', Pool02DOB='$_Pool02DOB', Pool03DOB='$_Pool03DOB', Pool04DOB='$_Pool04DOB', Pool05DOB='$_Pool05DOB', Pool06DOB='$_Pool06DOB', Pool07DOB='$_Pool07DOB', Pool08DOB='$_Pool08DOB', Pool09DOB='$_Pool09DOB', Pool10DOB='$_Pool10DOB', Pool11DOB='$_Pool11DOB', Pool12DOB='$_Pool12DOB', Pool13DOB='$_Pool13DOB', Pool14DOB='$_Pool14DOB', Pool15DOB='$_Pool15DOB', Pool16DOB='$_Pool16DOB', Pool17DOB='$_Pool17DOB', Pool18DOB='$_Pool18DOB', Pool19DOB='$_Pool19DOB', Pool20DOB='$_Pool20DOB' WHERE ContactID='$_ContactID'"; $query = mysql_query($sql); if ($query) { exit; } mysql_close(); ?> <center><ul id="tabs"> <a href="return_contacts_list.php?username=<?php echo $Account;?>&password=<?php echo $AccountID;?>">User List</a> <a href="user_details.php?ContactID=<?php echo $ContactID;?>&AccountID=<?php echo $AccountID;?>">User Details</a> <a href="escalation_details.php?ContactID=<?php echo $ContactID;?>&AccountID=<?php echo $AccountID;?>">Escalation Details</a> <a href="pool_users.php?ContactID=<?php echo $ContactID;?>&AccountID=<?php echo $AccountID;?>">Pool Users</a> </ul> <BR> <a href="logout.html">Logout</a> </body> </html> The main issue is: <a href="return_contacts_list.php?username=<?php echo $Account;?>&password=<?php echo $AccountID;?>">User List</a> when i hover over the link it just shows /username=password= it should show something like /username=joebloggspassword=GIYGUU67 This works fine on my other pages, its only on my UPDATE pages that it fails... Could anyone point out what im doing wrong. Sorry if that was long winded. Thanks in advance. Quote Link to comment https://forums.phpfreaks.com/topic/267742-adding-a-mysql-variable-to-html-via-php/ Share on other sites More sharing options...
Jessica Posted August 29, 2012 Share Posted August 29, 2012 Holy moly. 1. Right away you try to use $AccountID without defining it. If it's coming from the original URL, you need to use $AccountID = $_GET['AccountID']; 2. Next, read about sanitizing user input and SQL injection. 3. All this: "$_REQUEST["Pool01Name"]; $_REQUEST["Pool02Name"];" Stuff? You don't do anything with them the first time, those lines do nothing. Secondly, you should be using an array for this data. $_Pool01Name = $_REQUEST["Pool01Name"]; $_Pool02Name = $_REQUEST["Pool02Name"]; Should be an array. 4. Your update uses $ContactID, which is also never defined. 5. if ($query) { exit; } This is the opposite of what you want. You also aren't capturing any MySQL errors to help you. 6. Turn on error reporting!! Quote Link to comment https://forums.phpfreaks.com/topic/267742-adding-a-mysql-variable-to-html-via-php/#findComment-1373551 Share on other sites More sharing options...
dark_destroyer Posted August 29, 2012 Author Share Posted August 29, 2012 Hi Jesirose, thanks for the detailed reply, i'm revisiting PHP/MySQL for the first time in many years, actually using code i wrote in college many moons ago.. Appreciate the comments on sanitizing and sql injection, looks like i need to do some more reading up. I have amended the code now (PS the update always worked fine.. so $ContactID must have been working somehow..) i now have: <?php $_AccountID = $_GET['AccountID']; $_Account = $_GET['Account']; $_ContactID = $_GET['ContactID']; The update still works so it must mean that the variables are declared and are actually pulling in information. However, i still cannot seem to pass the variable to the HTML code outside the PHP code. Actually, i cannot get the webpage to display anything, its just a blank, i would have thought that at least it would have displayed the links, even if they were useless. here: if ($query) { exit; } mysql_close(); ?> <center><ul id="tabs"> <a href="return_contacts_list.php?username=<?php echo $_Account;?>&password=<?php echo $_AccountID;?>">User List</a> <a href="user_details.php?ContactID=<?php echo $_ContactID;?>&AccountID=<?php echo $_AccountID;?>">User Details</a> <a href="escalation_details.php?ContactID=<?php echo $_ContactID;?>&AccountID=<?php echo $_AccountID;?>">Escalation Details</a> <a href="pool_users.php?ContactID=<?php echo $_ContactID;?>&AccountID=<?php echo $_AccountID;?>">Pool Users</a> </ul> <BR> <a href="logout.html">Logout</a> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/267742-adding-a-mysql-variable-to-html-via-php/#findComment-1373578 Share on other sites More sharing options...
Jessica Posted August 29, 2012 Share Posted August 29, 2012 See my point #5. Quote Link to comment https://forums.phpfreaks.com/topic/267742-adding-a-mysql-variable-to-html-via-php/#findComment-1373580 Share on other sites More sharing options...
dark_destroyer Posted August 29, 2012 Author Share Posted August 29, 2012 Thanks, I changed it too: if ($query) { ini_set('display_errors',1); error_reporting(E_ALL); } mysql_close(); ?> <center><ul id="tabs"> <a href="return_contacts_list.php?username=<?php echo $_Account;?>&password=<?php echo $_AccountID;?>">User List</a> <a href="user_details.php?ContactID=<?php echo $_ContactID;?>&AccountID=<?php echo $_AccountID;?>">User Details</a> <a href="escalation_details.php?ContactID=<?php echo $_ContactID;?>&AccountID=<?php echo $_AccountID;?>">Escalation Details</a> <a href="pool_users.php?ContactID=<?php echo $_ContactID;?>&AccountID=<?php echo $_AccountID;?>">Pool Users</a> </ul> <BR> <a href="logout.html">Logout</a> I now get a value in my links for $_Account and $_ContactID, but not for $_AccountID, ill keep working on it and post the result if i fix it. Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/267742-adding-a-mysql-variable-to-html-via-php/#findComment-1373584 Share on other sites More sharing options...
Jessica Posted August 29, 2012 Share Posted August 29, 2012 Wow, not quite what I meant. What do you WANT to do if your query succeeds? What is the URL query string? Quote Link to comment https://forums.phpfreaks.com/topic/267742-adding-a-mysql-variable-to-html-via-php/#findComment-1373585 Share on other sites More sharing options...
dark_destroyer Posted August 29, 2012 Author Share Posted August 29, 2012 Hi, After the insert, i simply want to pass the variables, $_AccountID, $_Account, $_ContactID to the URL's, I can see the variables for the last 2, but not $_AccountID. THis is how i have defined them: $_AccountID = $_GET['AccountID']; $_Account = $_GET['Account']; $_ContactID = $_GET['ContactID']; $_AccountID is the one giving me a headache.. here is the full code i have used: <html> <head> <title>PeopleSafe</title> </head> <body> <?php $_AccountID = $_GET['AccountID']; $_Account = $_GET['Account']; $_ContactID = $_GET['ContactID']; $_FirstName = $_REQUEST["FirstName"]; $_LastName = $_REQUEST["LastName"]; $_Pool01Name = $_REQUEST["Pool01Name"]; $_Pool02Name = $_REQUEST["Pool02Name"]; $_Pool03Name = $_REQUEST["Pool03Name"]; $_Pool04Name = $_REQUEST["Pool04Name"]; $_Pool05Name = $_REQUEST["Pool05Name"]; $_Pool06Name = $_REQUEST["Pool06Name"]; $_Pool07Name = $_REQUEST["Pool07Name"]; $_Pool08Name = $_REQUEST["Pool08Name"]; $_Pool09Name = $_REQUEST["Pool09Name"]; $_Pool10Name = $_REQUEST["Pool10Name"]; $_Pool11Name = $_REQUEST["Pool11Name"]; $_Pool12Name = $_REQUEST["Pool12Name"]; $_Pool13Name = $_REQUEST["Pool13Name"]; $_Pool14Name = $_REQUEST["Pool14Name"]; $_Pool15Name = $_REQUEST["Pool15Name"]; $_Pool16Name = $_REQUEST["Pool16Name"]; $_Pool17Name = $_REQUEST["Pool17Name"]; $_Pool18Name = $_REQUEST["Pool18Name"]; $_Pool19Name = $_REQUEST["Pool19Name"]; $_Pool20Name = $_REQUEST["Pool20Name"]; $_Pool01Number = $_REQUEST["Pool01Number"]; $_Pool02Number = $_REQUEST["Pool02Number"]; $_Pool03Number = $_REQUEST["Pool03Number"]; $_Pool04Number = $_REQUEST["Pool04Number"]; $_Pool05Number = $_REQUEST["Pool05Number"]; $_Pool06Number = $_REQUEST["Pool06Number"]; $_Pool07Number = $_REQUEST["Pool07Number"]; $_Pool08Number = $_REQUEST["Pool08Number"]; $_Pool09Number = $_REQUEST["Pool09Number"]; $_Pool10Number = $_REQUEST["Pool10Number"]; $_Pool11Number = $_REQUEST["Pool11Number"]; $_Pool12Number = $_REQUEST["Pool12Number"]; $_Pool13Number = $_REQUEST["Pool13Number"]; $_Pool14Number = $_REQUEST["Pool14Number"]; $_Pool15Number = $_REQUEST["Pool15Number"]; $_Pool16Number = $_REQUEST["Pool16Number"]; $_Pool17Number = $_REQUEST["Pool17Number"]; $_Pool18Number = $_REQUEST["Pool18Number"]; $_Pool19Number = $_REQUEST["Pool19Number"]; $_Pool20Number = $_REQUEST["Pool20Number"]; $_Pool01DOB = $_REQUEST["Pool01DOB"]; $_Pool02DOB = $_REQUEST["Pool02DOB"]; $_Pool03DOB = $_REQUEST["Pool03DOB"]; $_Pool04DOB = $_REQUEST["Pool04DOB"]; $_Pool05DOB = $_REQUEST["Pool05DOB"]; $_Pool06DOB = $_REQUEST["Pool06DOB"]; $_Pool07DOB = $_REQUEST["Pool07DOB"]; $_Pool08DOB = $_REQUEST["Pool08DOB"]; $_Pool09DOB = $_REQUEST["Pool09DOB"]; $_Pool10DOB = $_REQUEST["Pool10DOB"]; $_Pool11DOB = $_REQUEST["Pool11DOB"]; $_Pool12DOB = $_REQUEST["Pool12DOB"]; $_Pool13DOB = $_REQUEST["Pool13DOB"]; $_Pool14DOB = $_REQUEST["Pool14DOB"]; $_Pool15DOB = $_REQUEST["Pool15DOB"]; $_Pool16DOB = $_REQUEST["Pool16DOB"]; $_Pool17DOB = $_REQUEST["Pool17DOB"]; $_Pool18DOB = $_REQUEST["Pool18DOB"]; $_Pool19DOB = $_REQUEST["Pool19DOB"]; $_Pool20DOB = $_REQUEST["Pool20DOB"]; $link = mysql_connect("localhost", "xxxxxx","xxxxxx") or die(mysql_error()); if (!$link) { die('Could not connect: ' . mysql_error()); } mysql_select_db("peoplesafe") or die(mysql_error()); $sql="UPDATE contacts SET Pool01Name='$_Pool01Name', Pool02Name='$_Pool02Name', Pool03Name='$_Pool03Name', Pool04Name='$_Pool04Name', Pool05Name='$_Pool05Name', Pool06Name='$_Pool06Name', Pool07Name='$_Pool07Name', Pool08Name='$_Pool08Name', Pool09Name='$_Pool09Name', Pool10Name='$_Pool10Name', Pool11Name='$_Pool11Name', Pool12Name='$_Pool12Name', Pool13Name='$_Pool13Name', Pool14Name='$_Pool14Name', Pool15Name='$_Pool15Name', Pool16Name='$_Pool16Name', Pool17Name='$_Pool17Name', Pool18Name='$_Pool18Name', Pool19Name='$_Pool19Name', Pool20Name='$_Pool20Name', Pool01Number='$_Pool01Number', Pool02Number='$_Pool02Number', Pool03Number='$_Pool03Number', Pool04Number='$_Pool04Number', Pool05Number='$_Pool05Number', Pool06Number='$_Pool06Number', Pool07Number='$_Pool07Number', Pool08Number='$_Pool08Number', Pool09Number='$_Pool09Number', Pool10Number='$_Pool10Number', Pool11Number='$_Pool11Number', Pool12Number='$_Pool12Number', Pool13Number='$_Pool13Number', Pool14Number='$_Pool14Number', Pool15Number='$_Pool15Number', Pool16Number='$_Pool16Number', Pool17Number='$_Pool17Number', Pool18Number='$_Pool18Number', Pool19Number='$_Pool19Number', Pool20Number='$_Pool20Number', Pool01DOB='$_Pool01DOB', Pool02DOB='$_Pool02DOB', Pool03DOB='$_Pool03DOB', Pool04DOB='$_Pool04DOB', Pool05DOB='$_Pool05DOB', Pool06DOB='$_Pool06DOB', Pool07DOB='$_Pool07DOB', Pool08DOB='$_Pool08DOB', Pool09DOB='$_Pool09DOB', Pool10DOB='$_Pool10DOB', Pool11DOB='$_Pool11DOB', Pool12DOB='$_Pool12DOB', Pool13DOB='$_Pool13DOB', Pool14DOB='$_Pool14DOB', Pool15DOB='$_Pool15DOB', Pool16DOB='$_Pool16DOB', Pool17DOB='$_Pool17DOB', Pool18DOB='$_Pool18DOB', Pool19DOB='$_Pool19DOB', Pool20DOB='$_Pool20DOB' WHERE ContactID='$_ContactID'"; $query = mysql_query($sql); if ($query) { ini_set('display_errors',1); error_reporting(E_ALL); } echo "ContactID: ".$_ContactID; echo "<BR>"; echo "AccountID: ".$_AccountID; mysql_close(); ?> <center><ul id="tabs"> <a href="return_contacts_list.php?username=<?php echo $_Account;?>&password=<?php echo $_AccountID;?>">User List</a> <a href="user_details.php?ContactID=<?php echo $_ContactID;?>&AccountID=<?php echo $_AccountID;?>">User Details</a> <a href="escalation_details.php?ContactID=<?php echo $_ContactID;?>&AccountID=<?php echo $_AccountID;?>">Escalation Details</a> <a href="pool_users.php?ContactID=<?php echo $_ContactID;?>&AccountID=<?php echo $_AccountID;?>">Pool Users</a> </ul> <BR> <a href="logout.html">Logout</a> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/267742-adding-a-mysql-variable-to-html-via-php/#findComment-1373588 Share on other sites More sharing options...
Jessica Posted August 29, 2012 Share Posted August 29, 2012 THis is how i have defined them: $_AccountID = $_GET['AccountID']; $_Account = $_GET['Account']; $_ContactID = $_GET['ContactID']; And so what does your URL look like? If you add print_r($_GET); to the top of the program, what is echod? Quote Link to comment https://forums.phpfreaks.com/topic/267742-adding-a-mysql-variable-to-html-via-php/#findComment-1373590 Share on other sites More sharing options...
dark_destroyer Posted August 29, 2012 Author Share Posted August 29, 2012 If i add in the echo i get: Array ( [ContactID] => AAABBBBCCC [Account] => ACME LTD [Pool01Name] => test2 [Pool01Number] => [PoolDOB01] => 0000-00-00 [Pool02Name] => test3 [Pool02Number] => [PoolDOB02] => 0000-00-00 [Pool03Name] => test4 [Pool03Number] => [PoolDOB03] => 0000-00-00 [Pool04Name] => [Pool04Number] => [PoolDOB04] => 0000-00-00 [Pool05Name] => [Pool05Number] => [PoolDOB05] => 0000-00-00 [Pool06Name] => [Pool06Number] => [PoolDOB06] => 0000-00-00 [Pool07Name] => [Pool07Number] => [PoolDOB07] => 0000-00-00 [Pool08Name] => [Pool08Number] => [PoolDOB08] => 0000-00-00 [Pool09Name] => [Pool09Number] => [PoolDOB09] => 0000-00-00 [Pool10Name] => [Pool10Number] => [PoolDOB10] => 0000-00-00 ) 1 So is this telling me that $_AccountID isnt pulling a value? My url should look like: http://localhost/user_details.php?ContactID=AAABBBBCCC&AccountID=DDDEEEFFF Quote Link to comment https://forums.phpfreaks.com/topic/267742-adding-a-mysql-variable-to-html-via-php/#findComment-1373598 Share on other sites More sharing options...
Jessica Posted August 29, 2012 Share Posted August 29, 2012 What do you mean should? Does it or doesn't it? Quote Link to comment https://forums.phpfreaks.com/topic/267742-adding-a-mysql-variable-to-html-via-php/#findComment-1373604 Share on other sites More sharing options...
dark_destroyer Posted August 29, 2012 Author Share Posted August 29, 2012 Hi, no the AccountID is just blank http://localhost/user_details.php?ContactID=AAABBBBCCC&AccountID= when it should be http://localhost/user_details.php?ContactID=AAABBBBCCC&AccountID=DDDEEEFFF Thanks Quote Link to comment https://forums.phpfreaks.com/topic/267742-adding-a-mysql-variable-to-html-via-php/#findComment-1373645 Share on other sites More sharing options...
Jessica Posted August 29, 2012 Share Posted August 29, 2012 So... why is that? We're talking about the URL of the page you are on, not the links. Why do you think that URL doesn't have the AccountID? Quote Link to comment https://forums.phpfreaks.com/topic/267742-adding-a-mysql-variable-to-html-via-php/#findComment-1373646 Share on other sites More sharing options...
dark_destroyer Posted August 29, 2012 Author Share Posted August 29, 2012 thats where im really struggling.. i would have thought that since the URL on the link containts the contactid and accountid, and it populates the contactid it would also populate the accountid. Since the contactid and accountid are declared in the same manner: $_AccountID = $_GET['AccountID']; $_Account = $_GET['Account']; $_ContactID = $_GET['ContactID']; i would have thought that it was passed to the URL link in the same way? Quote Link to comment https://forums.phpfreaks.com/topic/267742-adding-a-mysql-variable-to-html-via-php/#findComment-1373649 Share on other sites More sharing options...
Jessica Posted August 29, 2012 Share Posted August 29, 2012 No, the URL on the page that you are on. Look at your browser. What does THAT url say. The one that is running this code. Quote Link to comment https://forums.phpfreaks.com/topic/267742-adding-a-mysql-variable-to-html-via-php/#findComment-1373652 Share on other sites More sharing options...
dark_destroyer Posted August 29, 2012 Author Share Posted August 29, 2012 http://localhost/update_pool_details.php?ContactID=FSWRG2456&Account=ACME+LTD&Pool01Name=test2&Pool01Number=&PoolDOB01=0000-00-00&Pool02Name=test3&Pool02Number=&PoolDOB02=0000-00-00&Pool03Name=test4&Pool03Number=&PoolDOB03=0000-00-00&Pool04Name=&Pool04Number=&PoolDOB04=0000-00-00&Pool05Name=&Pool05Number=&PoolDOB05=0000-00-00&Pool06Name=&Pool06Number=&PoolDOB06=0000-00-00&Pool07Name=&Pool07Number=&PoolDOB07=0000-00-00&Pool08Name=&Pool08Number=&PoolDOB08=0000-00-00&Pool09Name=&Pool09Number=&PoolDOB09=0000-00-00&Pool10Name=&Pool10Number=&PoolDOB10=0000-00-00 Quote Link to comment https://forums.phpfreaks.com/topic/267742-adding-a-mysql-variable-to-html-via-php/#findComment-1373680 Share on other sites More sharing options...
Jessica Posted August 29, 2012 Share Posted August 29, 2012 Are you still confused about why when you visit that page, $_GET['AccountID'] is empty? Quote Link to comment https://forums.phpfreaks.com/topic/267742-adding-a-mysql-variable-to-html-via-php/#findComment-1373683 Share on other sites More sharing options...
dark_destroyer Posted August 30, 2012 Author Share Posted August 30, 2012 still very much confused, i have tried adding the $_AccoundID into the mysql insert statement, but it fails as $_AccountID is blank. when i do that i get the $_AccountID in the URL but it is blank. Im lost... completley lost... Quote Link to comment https://forums.phpfreaks.com/topic/267742-adding-a-mysql-variable-to-html-via-php/#findComment-1373787 Share on other sites More sharing options...
Jessica Posted August 30, 2012 Share Posted August 30, 2012 Do you know what $_GET is? Quote Link to comment https://forums.phpfreaks.com/topic/267742-adding-a-mysql-variable-to-html-via-php/#findComment-1373839 Share on other sites More sharing options...
dark_destroyer Posted August 30, 2012 Author Share Posted August 30, 2012 I have toyed around with $_GET and $_POST, i understand them at a basic level.. but im still not sure why, that when AccountID and ContactID are declared, only the ContactID is being pulled through. Quote Link to comment https://forums.phpfreaks.com/topic/267742-adding-a-mysql-variable-to-html-via-php/#findComment-1373941 Share on other sites More sharing options...
Jessica Posted August 30, 2012 Share Posted August 30, 2012 You said this is your URL. http://localhost/update_pool_details.php?ContactID=FSWRG2456&Account=ACME+LTD&Pool01Name=test2&Pool01Number=&PoolDOB01=0000-00-00&Pool02Name=test3&Pool02Number=&PoolDOB02=0000-00-00&Pool03Name=test4&Pool03Number=&PoolDOB03=0000-00-00&Pool04Name=&Pool04Number=&PoolDOB04=0000-00-00&Pool05Name=&Pool05Number=&PoolDOB05=0000-00-00&Pool06Name=&Pool06Number=&PoolDOB06=0000-00-00&Pool07Name=&Pool07Number=&PoolDOB07=0000-00-00&Pool08Name=&Pool08Number=&PoolDOB08=0000-00-00&Pool09Name=&Pool09Number=&PoolDOB09=0000-00-00&Pool10Name=&Pool10Number=&PoolDOB10=0000-00-00 You say you understand what $_GET is. But you don't understand why THAT url will not give you a value for $_GET['AccountID']. Quote Link to comment https://forums.phpfreaks.com/topic/267742-adding-a-mysql-variable-to-html-via-php/#findComment-1373943 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.