DeepakJ Posted July 30, 2007 Share Posted July 30, 2007 <html><head><title>AlibreCam Verification System</title></head> <center><TABLE border=0 cellpadding=3><form name="input" action="linput.php" method="get"> <tr> <td>Customer ID:</td> <td><input type="text" name="user"></td> </tr> <tr> <td>Product ID:</td> <td> <input type="text" name="user1"></td> </tr> <tr> <td colspan=2><center><input type="submit" value="Submit"></center></td> </tr> </form><br></table><br> <?php $hostname = "localhost"; $username = "root"; $password = "98989lol"; $dbname = "licensinginformation"; $customerid = $_GET['user']; $productid = $_GET['user1']; mysql_connect($hostname, $username, $password) or DIE("Unable to connect to MySQL server $hostname"); $selected = mysql_select_db($dbname) or DIE("Could not select requested db $dbname"); $querya = "SELECT * FROM invoiceid WHERE customerid='$customerid'"; $aResult = mysql_query($querya); while($row1=mysql_fetch_array($aResult)){ $invoicenum[]= $row1['invoicenum']; } $queryd = "SELECT * FROM invoiceid, productid WHERE invoiceid.invoicenum = productid.invoicenum && customerid= '$customerid'"; //queryd = "SELECT * FROM productid WHERE invoicenum IN('" . implode("', '", $invoicenum) . "')"; $dResult = mysql_query($queryd) or die(mysql_error()); $boolean = false; while($row2=mysql_fetch_array($dResult)){ if ($row2['productid']="") { $tableid = $row2['tableid']; $queryc = "UPDATE productid SET productid='$productid' WHERE tableid = '$tableid'"; mysql_query($queryc) or die(mysql_error()); echo "Data successfully entered."; $boolean = true; break; } } if ($boolean=false){ echo "The customer does not have enough licenses."; } ?> </html> Please help. Quote Link to comment Share on other sites More sharing options...
almightyegg Posted July 30, 2007 Share Posted July 30, 2007 We can't tell unless you give us some details... for instance, does it show any errors? Quote Link to comment Share on other sites More sharing options...
DeepakJ Posted July 31, 2007 Author Share Posted July 31, 2007 Thats the thing. No errors. Yet when I run the script, the database is not updated and the messages(both) wont show up This is my revised code: <html><head><title>AlibreCam Verification System</title></head> <center><TABLE border=0 cellpadding=3><form name="input" action="linput.php" method="get"> <tr> <td>Customer ID:</td> <td><input type="text" name="user"></td> </tr> <tr> <td>Product ID:</td> <td> <input type="text" name="user1"></td> </tr> <tr> <td colspan=2><center><input type="submit" value="Submit"></center></td> </tr> </form><br></table><br> <?php $hostname = "localhost"; $username = "root"; $password = "98989lol"; $dbname = "licensinginformation"; $customerid = $_GET['user']; $productid = $_GET['user1']; mysql_connect($hostname, $username, $password) or DIE("Unable to connect to MySQL server $hostname"); $selected = mysql_select_db($dbname) or DIE("Could not select requested db $dbname"); $querya = "SELECT * FROM invoiceid WHERE customerid='$customerid'"; $aResult = mysql_query($querya); while($row1=mysql_fetch_array($aResult)){ $invoicenum[]= $row1['invoicenum']; } $queryd = "SELECT * FROM invoiceid, productid WHERE invoiceid.invoicenum = productid.invoicenum && customerid= '$customerid'"; //queryd = "SELECT * FROM productid WHERE invoicenum IN('" . implode("', '", $invoicenum) . "')"; $dResult = mysql_query($queryd) or die(mysql_error()); $boolean = false; while($row2=mysql_fetch_array($dResult)){ if ($row2['productid']="") { $tableid = $row2['tableid']; $queryc = "UPDATE productid SET productid='$productid' WHERE tableid = '$tableid'"; mysql_query($queryc) or die(mysql_error()); echo "Data successfully entered."; $boolean = true; break; } } if ($boolean=false){ echo "The customer does not have enough licenses."; } ?> </html> Quote Link to comment Share on other sites More sharing options...
Iceman512 Posted July 31, 2007 Share Posted July 31, 2007 Hi DeepakJ, Are these scripts seperate, as in the PHP is seperate from the HTML? If so, you need a 'handle' (sorry - I don't know the correct terms!) for the script to react to. Try firstly naming the submit button like this: <input type="submit" name="formSent" value="Submit"> Then have the script react accordingly by putting this above the script on the PHP page: <?php if (isset($_POST['formSent']){ ?> and at the very end of the script put the closing bracket and maybe an else statement. Example: <?php } else { echo 'An unkonwn error has occured!'; } ?> Hope that helps! Regards, Iceman Quote Link to comment Share on other sites More sharing options...
Iceman512 Posted July 31, 2007 Share Posted July 31, 2007 ... sorry, I've just spotted your most likely problem. Change the method to "post": <form action="something.php" method="post"> You will also have to modify your PHP as follows: Change: <?php $customerid = $_GET['user']; $productid = $_GET['user1']; ?> To: <?php $customerid = $_POST['user']; $productid = $_POST['user1']; ?> Hope that works! Iceman Quote Link to comment Share on other sites More sharing options...
DeepakJ Posted July 31, 2007 Author Share Posted July 31, 2007 No its fine. Its a looping script. The php/html are in the same file. This works for all of my other input forms except this. I'm sure it is a syntax error or something that won't turn up. Quote Link to comment Share on other sites More sharing options...
DeepakJ Posted July 31, 2007 Author Share Posted July 31, 2007 That shouldn't matter. I use get for all my other SQL scripts. Ill try it anyways though. Quote Link to comment Share on other sites More sharing options...
DeepakJ Posted July 31, 2007 Author Share Posted July 31, 2007 Nope doens't work Quote Link to comment Share on other sites More sharing options...
Iceman512 Posted July 31, 2007 Share Posted July 31, 2007 Even if the form is on it's own, it might still need conditional handling. If the button has been clicked, do this action. If it hasn't, do that action, as it were. <?php if (!isset($_POST['formSent']){ <center><TABLE border=0 cellpadding=3><form name="input" action="linput.php" method="get"> <tr> <td>Customer ID:</td> <td><input type="text" name="user"></td> </tr> <tr> <td>Product ID:</td> <td> <input type="text" name="user1"></td> </tr> <tr> <td colspan=2><center><input type="submit" name="formSent" value="Submit"></center></td> </tr> </form><br></table><br> }elseif (isset($_POST['formSent']){ $hostname = "localhost"; $username = "root"; $password = "98989lol"; $dbname = "licensinginformation"; $customerid = $_GET['user']; $productid = $_GET['user1']; mysql_connect($hostname, $username, $password) or DIE("Unable to connect to MySQL server $hostname"); $selected = mysql_select_db($dbname) or DIE("Could not select requested db $dbname"); $querya = "SELECT * FROM invoiceid WHERE customerid='$customerid'"; $aResult = mysql_query($querya); while($row1=mysql_fetch_array($aResult)){ $invoicenum[]= $row1['invoicenum']; } $queryd = "SELECT * FROM invoiceid, productid WHERE invoiceid.invoicenum = productid.invoicenum && customerid= '$customerid'"; //queryd = "SELECT * FROM productid WHERE invoicenum IN('" . implode("', '", $invoicenum) . "')"; $dResult = mysql_query($queryd) or die(mysql_error()); $boolean = false; while($row2=mysql_fetch_array($dResult)){ if ($row2['productid']="") { $tableid = $row2['tableid']; $queryc = "UPDATE productid SET productid='$productid' WHERE tableid = '$tableid'"; mysql_query($queryc) or die(mysql_error()); echo "Data successfully entered."; $boolean = true; break; } } if ($boolean=false){ echo "The customer does not have enough licenses."; } } else { echo 'An unknown error has occurred.'; } ?> Maybe that will help? Quote Link to comment Share on other sites More sharing options...
DeepakJ Posted July 31, 2007 Author Share Posted July 31, 2007 Doesn't work Quote Link to comment Share on other sites More sharing options...
mdnghtblue Posted July 31, 2007 Share Posted July 31, 2007 Just a note: if ($boolean=false){ echo "The customer does not have enough licenses."; should probably be if (!$boolean){ echo "The customer does not have enough licenses."; 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.