troubleshooting Question

Programming (php, Javascript) not working

Avatar of Richard Korts
Richard KortsFlag for United States of America asked on
HTMLPHPJavaScript
8 Comments1 Solution88 ViewsLast Modified:
I have this code in program 1:
<!DOCTYPE html>

<html>
<head>
<title>Print Single Form</title>
<meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
    <link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>

    <script src="//code.jquery.com/jquery-1.10.2.js"></script>
    <script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
    <link rel="stylesheet" href="/resources/demos/style.css">

    <title>Backflow Assembly & Test Report Form</title>
    <style>
        .nopadding {
            padding: 0 !important;
            margin: 0 !important;
        }
        
        .wrapper {
            max-width: 767px;
            min-width: 480px;
            margin: 0 auto;
        }
    </style>
	<script>
	user = <? print $_SESSION['user']; ?>;
	fname = "<? print $fname; ?>";
	ac = "";
	fr = "<? print $fr; ?>";
	ems = "<? print $_GET['ems']; ?>";
	loc = "<? print $loc; ?>";
	function open_pdf_win() {
		str = loc + fname;	
		window.open(str);
	}
	function ask_email() {
		jj = confirm("Email printed form to my email?");
		if (jj) {
			window.location = "email_pdf_new.php?f=" + fname;
		}
		window.location = "print_cleanup.php?fr=" + fr + "&ems=Y";
	}
	</script>
</head>
	<body onLoad="open_pdf_win(); ask_email();"> 
	<? if ($_GET['ems'] != "y") {?>
		<body onLoad="ask_email();">
	<? } ?>	
</body>
</html>

It displays the confirm, I answer yes.

Unless I'm missing something basic (maybe I am), it goes to email_pdf_new.php.

Code for that is this:

<?php
//echo "entered email_pdf_new<br>";
// email_pdf.php
session_start();
// use phpmailer
$f = $_GET['f'];
if ($_SESSION['user'] == 2) {
	echo "entered email_pdf_new<br>";
	echo "file = " . $f . "<br>";
}	
require_once('class.phpmailer.php');
$mail             = new PHPMailer(); // defaults to using php "mail()"

$mail->isSMTP(); // telling the class to use SMTP transport
 
$body             = "";
 
$mail->SetFrom('noreply@backflowtestreport.com');
$mail->SMTPSecure = $GLOBALS['smtp_security'];
$mail->Port       = $GLOBALS['smtp_port'];
$mail->Subject   = "Completed form for " . $_SESSION['pn'];
$body = "Attached is the completed form for the subject property";
$mail->AddAddress(trim($_SESSION['email']));
$mail->AddAttachment($f);
$mail->MsgHTML($body);
$mail->AltBody = strip_tags($body);
if(!$mail->Send()) {
	echo "Mailer Error: " . $mail->ErrorInfo;
} else {
	//echo "sent email";
	//echo "going to choose_cust_new<br>";
	if (isset($_SESSION['narrow'])) {
		if ($_SESSION['narrow'] == "yes") {
			header("Location: choose_cust_ph.php?prop=" . $_GET['prop']);
			exit;
		}
	} else {	
		header("Location: choose_cust.php?prop=" . $_GET['prop']);
	}	
	exit;
	//echo $loc;
}		
?>

I am user where $_SESSION['user'] = 2. The echos do not display, which implies, it does not enter this program.

Why?

Thanks
ASKER CERTIFIED SOLUTION
David S.
Consultant & Challenge Subduer

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Top Expert 2009

The Distinguished Expert awards are presented to the top veteran and rookie experts to earn the most points in the top 50 topics.

Join our community to see this answer!
Unlock 1 Answer and 8 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 8 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros