query($sql); if ($result->num_rows > 0) { // output data of each row while($row = $result->fetch_assoc()) { $usr_alias = $row["usr_alias"]; } } else { echo "0 results"; } $conn->close(); $new_filename = 'Timesheet ' . $usr_alias . ' Week Ending '. $_GET['to_date'] ; $curl = curl_init(); curl_setopt_array($curl, array( //CURLOPT_URL => "http://160.119.100.178:8080/jasperserver/rest_v2/reports/Timesheets/".$_GET['reportid']."_1.pdf?from_date=".$_GET['from_date']."&to_date=".$_GET['to_date']."&KimaiUserId=".$_GET['kimaiuserid']."&j_username=jaco&j_password=Bollie0001", CURLOPT_URL => "https://reportserver.alteram.co.za/jasperserver/rest_v2/reports/Timesheets/".$_GET['reportid']."_1.pdf?from_date=".$_GET['from_date']."&to_date=".$_GET['to_date']."&KimaiUserId=".$_GET['kimaiuserid']."&j_username=jaco&j_password=Bollie0001", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "GET", CURLOPT_SSL_VERIFYPEER => false, // Disable peer verification CURLOPT_SSL_VERIFYHOST => false, )); header('Content-type:application/pdf'); header('Content-Disposition: inline; filename="' .$new_filename.'.pdf"'); $response = curl_exec($curl); curl_close($curl); echo $response; } ?>