php - Download pdf file on form submit -
i have form zoho crm:
<div id='crmwebtoentityform' align='center'> <meta http-equiv ='content-type' content='text/html;charset = utf-8'> <form action='http://crm.zoho.com/crm/webtoleadform' name=webtoleads1041232000000749005 method='post' onsubmit='javascript:document.charset="utf-8"; return checkmandatery()' accept-charset='utf-8'> <input type='text' style='display:none;' name='xnqsjsdp' value='fbc5a29ead008c324c3a5bad0887e5bf1f95d083f11d4251a6f8aa5a236fd104'/> <input type='hidden' name='zc_gad' id='zc_gad' value=''/> <input type='text' style='display:none;' name='xmiwtld' value='eecaf957dfe7083c05ed797b5ed94512300831df6a467c5c0dca55e1967f2eae'/> <input type='text' style='display:none;' name='actiontype' value='tgvhzhm='/> <input type='text' style='display:none;' name='returnurl' value='http://www.example.com/sucess-page' /> <br> <table border=0 cellspacing=0 cellpadding='6' width=600 style='background-color:white;color:black'> <tr> <td colspan='2' align='left' style='color:black;font-family:arial;font-size:14px;'><strong>after radical</strong></td> </tr> <br> <tr> <td nowrap='nowrap' align='left' style='font-size:12px;font-family:arial;width:200px;'>nombre </td><td style='width:250px;' ><input type='text' style='width:250px;' maxlength='40' name='first name' /></td> </tr> <tr> <td colspan='2' align='center' style='padding-top: 15px;' > <input style='font-size:12px;color:black' type='submit' value='submit' /> <input type='reset' style='font-size:12px;color:black' value='reset' /> </td> </tr> </table> </form> </div>
what want achieve on submit, user downloads pdf on same page. need avoid going other page , let them copy url download file without using/sending form.
the actual behavior of form on submit sends user http://crm.zoho.com/crm/webtoleadform
, loads page http://www.example.com/sucess-page
in input value. page different user sents form.
i've tried changing this:
form action='http://crm.zoho.com/crm/webtoleadform
to this:
form action='http://www.example.com/myfile.pdf
it works downloading pdf on same page (i added htaccess: addtype application/octet-stream .pdf
) form doesn't send user info zoho crm management.
any idea how achieve this? maybe jquery alternative?
post form same page. in php code, check if form has been submitted. if has, post same data crm page using curl , echo pdf link.
example:
<form method="post" action="?"> ... </form>
and check if form has been submitted...
if ($_server['request_method'] == 'post') { curlpostfunction(); echo "<a href='http://example.com/example.pdf'>click download</a>"; }
read link more info on how create function post using curl: curl post
note basic example -- code should include more checks based on how secure want implementation be.
Comments
Post a Comment