Jump to content

Target link not working


webchambers1

Recommended Posts

This link is driving me crazy

<a id ="savepdf" href="invoice.php?invoice_id=<?=$invoiceID?>"value="Save This Invoice"><button class="block" id ="printbtn" onclick="myFunction()";>Save Invoice</button></a>

 

when a user selects this link it works ok saves a pdf file to a folder on server.

i want to relocate after link submitted.

If i use this link it does redirect but does not save the pdf file to folder on server

<a id ="savepdf" href="invoice.php?invoice_id=<?=$invoiceID?>"value="Save This Invoice" onclick="window.location.href='mypage.php'; ;return false;"><button class="block" id ="printbtn" onclick="myFunction()";>Save Invoice</button></a>

Link to comment
Share on other sites

Sorry i thought posting the link would solve this. Ok i have a form once submitted it goes to invoice.php in invoice.php there are 2 buttons. One goes back to edit page if needed. The other button saves the page as a pdf file to a file on my server using dompdf. At the moment when you click save invoice an alert pops up with a reminder. Once you select ok it saves the page as a pdf file to a folder on the server but stays on the same page. I am trying to remove the alert and then once save invoice clicked it saves to file on folder and then shows another page?.

Here is full page invoice.php.

 

 invoice.php ( PHP script, ASCII text )

<?php require __DIR__.'/dompdf/autoload.inc.php'; require_once './controller.php'; use Dompdf\Dompdf; if(isset($_GET["invoice_id"]) && $_GET["invoice_id"]>0){ $invoiceID = $_GET["invoice_id"]; require_once './pdf.php'; $dompdf = new Dompdf(); $dompdf->loadHtml($html); $dompdf->render(); $output = $dompdf->output(); file_put_contents("./uploadinvoice/"."Invoice_Rose_Joinery_".$_GET["invoice_id"].".pdf", $output); $invoicename = isset($client["name"]) ? $client["name"] : ""; $invoiceaddress1 = isset($client["address1"]) ? $client["address1"] : ""; $invoiceaddress2 = isset($client["address2"]) ? $client["address2"] : ""; $invoiceaddress3 = isset($client["address3"]) ? $client["address3"] : ""; $invoiceaddress4 = isset($client["address4"]) ? $client["address4"] : ""; $invoiceaddress5 = isset($client["address5"]) ? $client["address5"] : ""; $invoiceitem1 =isset($invoice["invoiceitem1"]) ? $invoice["invoiceitem1"] :""; $invoiceitem2 =isset($invoice["invoiceitem2"]) ? $invoice["invoiceitem2"] :""; $invoiceitem3 =isset($invoice["invoiceitem3"]) ? $invoice["invoiceitem3"] :""; $invoiceitem4 =isset($invoice["invoiceitem4"]) ? $invoice["invoiceitem4"] :""; $invoiceitem5 =isset($invoice["invoiceitem5"]) ? $invoice["invoiceitem5"] :""; $invoiceitem6 =isset($invoice["invoiceitem6"]) ? $invoice["invoiceitem6"] :""; $invoiceitem7 =isset($invoice["invoiceitem7"]) ? $invoice["invoiceitem7"] :""; $invoiceitem1price = isset($invoice["invoiceitem1price"]) ? $invoice["invoiceitem1price"] : 0; $invoiceitem2price = isset($invoice["invoiceitem2price"]) ? $invoice["invoiceitem2price"] : 0; $invoiceitem3price = isset($invoice["invoiceitem3price"]) ? $invoice["invoiceitem3price"] : 0; $invoiceitem4price = isset($invoice["invoiceitem4price"]) ? $invoice["invoiceitem4price"] : 0; $invoiceitem5price = isset($invoice["invoiceitem5price"]) ? $invoice["invoiceitem5price"] : 0; $invoiceitem6price = isset($invoice["invoiceitem6price"]) ? $invoice["invoiceitem6price"] : 0; $invoiceitem7price = isset($invoice["invoiceitem7price"]) ? $invoice["invoiceitem7price"] : 0; $total = isset($invoice["total"]) ? $invoice["total"] : 0; $invoicedate = isset($invoice["invoiceDate"])? $invoice["invoiceDate"] :""; $invoicenumber = isset($invoice["invoiceNo"]) ? $invoice["invoiceNo"] : ""; $notes = isset($invoice["notes"]) ? $invoice["notes"] : ""; $sum1=$invoiceitem1price; $sum2=$invoiceitem2price; $sum3=$invoiceitem3price; $sum4=$invoiceitem4price; $sum5=$invoiceitem5price; $sum6=$invoiceitem6price; $sum7=$invoiceitem7price; $total = number_format($total, 2, ".", ""); $nameOfDay = $invoice["nameOfDay"]; $newDate = $invoice["created_at"]; } ?> <html> <head> <style type="text/css"> @media print { #printbtn { display : none; } } </style> <style type="text/css"> @media print { #backbtn { display : none; } } </style> <meta name="viewport" content="width=device-width,> <style> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <meta charset="utf-8"> <title>Invoice</title> <meta name="generator" content="WYSIWYG Web Builder 14 - http://www.wysiwygwebbuilder.com"> <style type="text/css"> div#container { width: 320px; position: relative; margin: 0 auto 0 auto; text-align: left; } body { background-color: #FFFFFF; color: #000000; font-family: Arial; font-weight: normal; font-size: 12px; line-height: 1.1875; margin: 15; text-align: left; } a { color: #0000FF; text-decoration: none; } a:hover { color: #FF0000; text-decoration: none; } input:focus, textarea:focus, select:focus { outline: none; } @media only screen and (max-width: 320px) { div#container { width: 320px; } body { background-color: #FFFFFF; } } </style> <style> .back { display: block; width: 100%; border: none; background-color: #4CAF50; color: #000000; padding: 14px 28px; font-size: 20px; font-weight: bold; cursor: pointer; text-align: center; } </style> <style> .block { display: block; width: 100%; border: none; background-color: #4CAF50; color: #000000; padding: 14px 28px; font-size: 20px; font-weight: bold; cursor: pointer; text-align: center; } </style> <script> function myFunction() { alert("Your invoice will be saved to your account. To view it select the 'View Invoices' link from your account menu. Please remember to log the amount of this invoice using the 'Income' link."); } </script> </head> <body onload="parent.scrollTo(0,0);"> <a href="javascript:history.go(-1)"><button class="block" id ="backbtn">Back To Edit</button></a><br> <a id ="savepdf" href="invoice.php?invoice_id=<?=$invoiceID?>" value="Save This Invoice"><button class="block" id ="printbtn" onclick="myFunction()">Save Invoice</button></a></a> <?php // ALTER THIS TO RETREIVE CUSTOMER DATA $row = getdata("company"); if (count($row) > 0) { // Company Logo Or Header echo '<div style="position:absolute;left:20px;top:140px;z-index:0;">'; echo '<img src="companylogo.png">'; echo '</div>'; echo '<div style="position:absolute;left:20px;top:320px;z-index:0;">'; echo "<H1>Customer Invoice <H1>"; echo '</div>'; // My Company Details echo '<div style="position:absolute;left:20px;top:370px;z-index:0;">'; echo "<H3>Invoice From <H3>"; echo '</div>'; echo '<div style="position:absolute;left:20px;top:400px;z-index:0;">'; echo "<h3>" .$row["MYNAME"]. " <br> " .$row["MYADDRESS1"]. " <br> " .$row["MYADDRESS2"]. " <br> " .$row["MYADDRESS3"]. " <br> " .$row["MYADDRESS4"]. " <br> " .$row["MYADDRESS5"]. "</h3>"; echo '</div>'; // Customer Details echo '<div style="position:absolute;left:500px;top:370px;z-index:0;">'; echo "<h3> Invoice To</h3>"; echo '</div>'; echo '<div style="position:absolute;left:500px;top:400px;z-index:0;">'; echo "<h3>$invoicename <br> $invoiceaddress1 <br> $invoiceaddress2 <br> $invoiceaddress3 <br> $invoiceaddress4 <br> $invoiceaddress5</h3>"; echo '</div>'; echo '<div style="position:absolute;left:20px;top:550px;z-index:0;">'; echo "<H3>Invoice Date : "; echo date("l d F Y", strtotime($newDate)); echo '</div>'; echo '<div style="position:absolute;left:20px;top:520px;z-index:0;">'; echo "<H3>Invoice Reference : $notes</H3>"; echo '</div>'; // Remove backlshes if these details required echo '<div style="position:absolute;left:500px;top:520px;z-index:0;">'; echo "<H3>Contact Number 07801798153</H3>"; echo '</div>'; echo '<div style="position:absolute;left:500px;top:545px;z-index:0;">'; echo "<H3>E Mail admin@mywebchambers.co.uk</H3>"; echo '</div>'; // End of extra details echo '<div style="position:absolute;left:20px;top:600px;z-index:0;">'; echo "<H3>Details : </H3>"; echo '</div>'; echo '<div style="position:absolute;left:20px;top:650px;z-index:0;">'; echo "<H2>Description</H2>"; echo '</div>'; echo '<div style="position:absolute;left:20px;top:650px;z-index:0;">'; echo "<H2>Description</H2>"; echo '</div>'; echo '<div style="position:absolute;left:700px;top:650px;z-index:0;">'; echo "<H2>Amount</H2>"; echo '</div>'; // Invoice Details echo "<H3><table width=800 cellpadding=10 style='position:absolute;left:10px;top:680px; z-index:0;'>"; echo '<tr><th width="500px"></th><th width="20px"></th><th width="100px"></th></tr>'; if($sum1!=""){ echo "<tr><td>$invoiceitem1</td><td></td><td>&pound $invoiceitem1price</td> "; } if($sum2!=""){ echo "<tr><td>$invoiceitem2</td><td></td><td>&pound $invoiceitem2price</td> "; } if($sum3!=""){ echo "<tr><td>$invoiceitem3</td><td></td><td>&pound $invoiceitem3price</td> "; } if($sum4!=""){ echo "<tr><td>$invoiceitem4</td><td></td><td>&pound $invoiceitem4price</td> "; } if($sum5!=""){ echo "<tr><td>$invoiceitem5</td><td></td><td>&pound $invoiceitem5price</td> "; } if($sum6!=""){ echo "<tr><td>$invoiceitem6</td><td></td><td>&pound $invoiceitem6price</td> "; } if($sum7!=""){ echo "<tr><td>$invoiceitem7</td><td></td><td>&pound $invoiceitem7price</td> "; } echo "<tr><th width='800px' align=right><br><br>Total Amount Now Due</th><th></th><th><br><br>&pound $total</th></tr>"; echo "</table></H3>"; } ?> </body> </html>

Link to comment
Share on other sites

I don't see that code attempting to do a redirect. Please post the version you tried to make do the redirect since that is, after all, the one that doesn't work.

When you do post it, please use the Code <> button so it doesn't end up as that blob.

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.