Jump to content

PHP POST page showing blank page


judejitsu

Recommended Posts

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.

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.