Avatar of Richard Korts
Richard Korts
Flag for United States of America

asked on 

Programming (php, Javascript) not working

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>

Open in new window


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;
}		
?>

Open in new window


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

Why?

Thanks
HTMLPHPJavaScript

Avatar of undefined
Last Comment
Richard Korts

8/22/2022 - Mon