texmansru47 Posted August 13, 2008 Share Posted August 13, 2008 Well I thought I had the proper logic (and I may) but I cannot see to figure out why it is not working: Scenario: I have a form that has php code behind it. When the user enters in the data there is a check that has to be made: 1) has the product been processed as "ALL GOOD" (that is where the product is ok, and was passed to shipping) 2) If the product was not ALL GOOD did it PASSED, if so enter a particular type of data for that record in the production and history tables. 3) if the product was not ALL GOOD and it FAILED, if so enter a particular amount of data in the production and history tables (see code below) The problem is if I flag data that is in the database as "All GOOD" the proper response occurs (I get the error message from the isset() statement being positive) but if the product I enter in is either PASSED or FAILED, nothing happens. I thought using a IF ELSEIF statement would be the proper validation point but either it is not or my INSERT code is all wrong. I have tried the INSERT code for the PASSED portion without any IF ELSE or IF ELSEIF statement and it wrote the proper date to the table, so I think it is correct. I'm just not sure why it is not working. Here is the code: <?php if (isset($_GET['param1']) && !empty($_GET['param1'])){ $prod=$_GET['param1']; echo "Your Prod Number is:\n$prod"; } elseif ($_SERVER['REQUEST_METHOD'] == 'POST'){ $imei=$_POST['param1']; echo "Your Bloody prod Number is:\n$prod"; // Main PHP code for connecting to the database for production processing $con = mysql_connect("localhost","user","xxxxxx") or die('Connection: ' . mysql_error());; mysql_select_db("logdata", $con) or die('Database: ' . mysql_error()); //Initial search and selection. $grabit = "SELECT * FROM `recv` WHERE `ProdNum` = '$prod'"; $testdata = mysql_query($grabit) or die(mysql_error()); $testit = mysql_fetch_assoc($testdata) or die(mysql_error()); //SQL query for is the Prod Number was completed fine, this will populate the PROD table accordingly. // variables for this section only! $ota =$_POST['TestResults']; $notes=$_POST['undernotes']; // variables from the SELECT Query $batch=$testit['BatchNum']; $sku=$testit['ModelSku']; $type=$testit['ModelType']; $serial=$testit['SerNum']; $card=$testit['CardType']; //Run the Select Query to gather the proper FailCode response from Table FailCode (Lookup Table) to populate the Prod/ProdHist Tables. $failcode = "SELECT * FROM `FailCode` WHERE `CodeID` = '$codeid'"; $faildata = mysql_query($failcode) or die(mysql_error()); $failrun = mysql_fetch_assoc($faildata) or die(mysql_error()); //Set variable from Fail Code SELECT process. $failit=$failrun['FailCode']; $failnotes=$_POST['FailNotes']; //Search the Prod Database for duplicates $findit = "SELECT * FROM `Prod` WHERE `ProdNum` = '$prod'"; $finddata = mysql_query($findit) or die(mysql_error()); $dataresults = mysql_fetch_assoc($finddata) or die(mysql_error()); // variables from the verification of AllGOOD Query $done=$dataresults['PassGood']; // Test loop of the data inputted to verify the data inputted into the table. if (isset($done) == 'Yes') { ?> <head> <script language="JavaScript"> alert("This Unit has been passed as ALL GOOD. Please forward to Kitting."); </script> </head> <?php } elseif ($ota == 'Passed'){ // INSERT Data into Prod Table. @mysql_query("INSERT INTO `Prod` (`BatchNum`,`ProdNum`,`SerNum`,`ModelSku`,`ModelType`,`CardType`,`TestResults`,`undernotes`,`DateRep`) VALUES ('$batch', '$prod','$serial','$sku','$type','$card','$ota','$notes', Now())") or die(mysql_error()); @mysql_query("DELETE FROM `Prod` WHERE `ProdNum` = 0"); //Insert this record into the SnaProd Database for historical purposes. mysql_query("INSERT INTO `ProdHist` SELECT * FROM `Prod` WHERE `IMEINum` = '$prod'") or die(mysql_error()); //Notifies the User that the record was successfully inputted into the Prod Table. print "<p>This record was updated in the History Table.</p>"; } else { // INSERT Data into Prod Table. @mysql_query("INSERT INTO `Prod` (`BatchNum`,`ProdNum`,`SerNum`,`ModelSku`,`ModelType`,`CardType`,`TestResults`,`undernotes`,`DateRep`) VALUES ('$batch', '$prod','$serial','$sku','$type','$card','$ota','$notes', Now())") or die(mysql_error()); @mysql_query("DELETE FROM `Prod` WHERE `ProdNum` = 0"); //Insert this record into the Prod Database for historical purposes. mysql_query("INSERT INTO `ProdHist` SELECT * FROM `Prod` WHERE `ProdNum` = '$prod'") or die(mysql_error()); //Notifies the User that the record was successfully inputted into the Prod Table. print "<p>This record was recorded as a FAILURE in the History Table.</p>"; mysql_close($con); } ?> The form is here: <!-- This section will create the form for the "Repair" Unit popup window. --> <form method="post" name="prod" action="repair.php"><font color="#000080" face="Arial"> <input type="hidden" name="param1" value="<?php echo $imei; ?>" /> <p><u><b><font size="2" font color="maroon" font type="Tahoma">Repair Section:</font></b></u></p> <p><font face="Arial" font size="2"> <b>OTA Pass/Fail: <select name="TestResults" size="1" name="TestResults"> <option value="NULL">--</option> <option value="Passed">Passed</option> <option value="Failed">Failed</option> </select></b></font> <font face="Arial" font size="2"><br> <b>Fail Code(If Failed): <select name="CodeID" size="1" name="CodeID"> <option value="0">No Fail</option> <option value="1">No Power</option> <option value="2">Not Recognized</option> <option value="3">No Connection</option> <option value="4">Unable to Boot</option> <option value="5">WLAN Fail</option> </select></b></font> <font face="Arial" font size="2"><br> <td <font color="Navy" size="3" face="Tahoma"><b>Fail (Other): </b></font></td> <td><input name="FailNotes" type="text" id="FailNotes" size="35"><br> <td <font color="Black" size="2" face="Tahoma">Notes: </font></td> <td><input name="undernotes" type="text" id="undernotes" size="35"> <p align="center"> <!-- <input type="submit" value="Repair Data Submit" name="submit"></p> --> <input type="submit" value="Repair Data Submit" name="submit" onclick="refresh_page();window.close()"></p> </td> </body> </form> <form method="post"> <input type="button" value="Close Window" onclick="window.close()"> </form> To recap: I get the proper response if the input is in the database is marked as ALL GOOD, but I cannot write data if the unit is not ALL GOOD and PASSED or FAILED. Any ideas? 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.