judejitsu Posted October 14, 2013 Share Posted October 14, 2013 Hi, quite new here. I am having trouble with a form I am submitting for processing. Here is my code. process.php <?php require("common.php"); if ($_POST['hdd1pn'] == $_POST['hdd2pn'] && $_POST['hdd2pn'] == $_POST['hdd3pn'] && $_POST['hdd3pn'] == $_POST['hdd4pn'] && $_POST['partnumber'] != NULL && $_POST['ctnumber'] != NULL && $_POST['4sn'] != NULL && $_POST['hdd1pn'] != NULL && $_POST['hdd1sn'] != NULL && $_POST['hdd2sn'] != NULL && $_POST['hdd3sn'] != NULL && $_POST['hdd4sn'] != NULL) { $check = "SELECT * FROM dmagorders WHERE ctnumber = :ctnumber"; $check_params = array(":ctnumber" => $_POST['ctnumber']); try { $stmt = $db->prepare($check); $res = $stmt->execute($check_params); } catch(PDOException $ex) { die("Failed to run query: " . $ex->getMessage()); } if($stmt->rowCount() != 0) { while( $row = $stmt->fetch()) { $foursncheck = $_POST['4sn']; $check_sst = "SELECT * FROM mag_res WHERE serialno LIKE '%$foursncheck%'"; try { $sststmt = $db->prepare($check_sst); $sstresult = $sststmt->execute(); } catch(PDOException $sstex) { die("Failed to run query: " . $sstex->getMessage()); } if($sststmt->rowCount() != 0) { $upd = "UPDATE dmagorders SET hdd1sn = :hdd1sn, hdd2sn = :hdd2sn, hdd3sn = :hdd3sn, hdd4sn = :hdd4sn, stage = :stage, status = :status, lasttouch = :lasttouch, lastupdate = :lastupdate WHERE ctnumber = :ctnumber AND 4sn = :4sn"; $params = array( ":ctnumber" => $_POST['ctnumber'], ":4sn"=> strtoupper(str_pad($_POST['4sn'], 8, "0", STR_PAD_LEFT)), ":hdd1sn"=> $_POST['hdd1sn'], ":hdd2sn"=> $_POST['hdd2sn'], ":hdd3sn"=> $_POST['hdd3sn'], ":hdd4sn"=> $_POST['hdd4sn'], ":stage" => "8", ":status" => "Packed and Shipped", ":lasttouch" => $_SESSION['user']['fname']." ".$_SESSION['user']['lname'], ":lastupdate" => date('F d, Y [ h:i:s A O ]'), ); try { $updstmt = $db->prepare($upd); $updres = $updstmt->execute($params); header("Location: pack-dmag.php?stat=success"); exit(); } catch(PDOException $updex) { die("Failed to run query: " . $updex->getMessage());; exit(); } } else { header("Location: pack-dmag.php?stat=nosstdata"); exit(); } } } } else { header("Location: pack-dmag.php?stat=nodata"); exit(); } My problem is that this page is actually working for some forms, however, sometimes, it just shows a blank page and doesn't redirect back to pack-dmag.php. There are also no errors or warning messages. Just a single blank page. Any help is greatly appreciated. I am just still learning PHP. If you have suggestions to optimize my code, it is also greatly appreciated. Quote Link to comment Share on other sites More sharing options...
requinix Posted October 14, 2013 Share Posted October 14, 2013 Your code won't do anything if the rowCount() == 0. Quote Link to comment Share on other sites More sharing options...
judejitsu Posted October 16, 2013 Author Share Posted October 16, 2013 Thanks for the heads up requinix. Really appreciate it! 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.