webchambers1 Posted June 24, 2020 Share Posted June 24, 2020 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> Quote Link to comment https://forums.phpfreaks.com/topic/310998-target-link-not-working/ Share on other sites More sharing options...
Barand Posted June 24, 2020 Share Posted June 24, 2020 Why not heed the reply you got last time you posted this link? Quote Link to comment https://forums.phpfreaks.com/topic/310998-target-link-not-working/#findComment-1579140 Share on other sites More sharing options...
requinix Posted June 24, 2020 Share Posted June 24, 2020 Make a normal link to invoice.php and have the script do the redirect. Quote Link to comment https://forums.phpfreaks.com/topic/310998-target-link-not-working/#findComment-1579141 Share on other sites More sharing options...
chambers9661 Posted June 25, 2020 Share Posted June 25, 2020 I tried that it didnt work Quote Link to comment https://forums.phpfreaks.com/topic/310998-target-link-not-working/#findComment-1579150 Share on other sites More sharing options...
requinix Posted June 25, 2020 Share Posted June 25, 2020 Then post the code for it so we can tell you what the problem was. Quote Link to comment https://forums.phpfreaks.com/topic/310998-target-link-not-working/#findComment-1579151 Share on other sites More sharing options...
chambers9661 Posted June 25, 2020 Share Posted June 25, 2020 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>£ $invoiceitem1price</td> "; } if($sum2!=""){ echo "<tr><td>$invoiceitem2</td><td></td><td>£ $invoiceitem2price</td> "; } if($sum3!=""){ echo "<tr><td>$invoiceitem3</td><td></td><td>£ $invoiceitem3price</td> "; } if($sum4!=""){ echo "<tr><td>$invoiceitem4</td><td></td><td>£ $invoiceitem4price</td> "; } if($sum5!=""){ echo "<tr><td>$invoiceitem5</td><td></td><td>£ $invoiceitem5price</td> "; } if($sum6!=""){ echo "<tr><td>$invoiceitem6</td><td></td><td>£ $invoiceitem6price</td> "; } if($sum7!=""){ echo "<tr><td>$invoiceitem7</td><td></td><td>£ $invoiceitem7price</td> "; } echo "<tr><th width='800px' align=right><br><br>Total Amount Now Due</th><th></th><th><br><br>£ $total</th></tr>"; echo "</table></H3>"; } ?> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/310998-target-link-not-working/#findComment-1579155 Share on other sites More sharing options...
requinix Posted June 25, 2020 Share Posted June 25, 2020 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. Quote Link to comment https://forums.phpfreaks.com/topic/310998-target-link-not-working/#findComment-1579165 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.