I have this form from zoho crm:
我有来自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 I want to achieve is that on submit, the user downloads a PDF on the same page. I need this to avoid going to other page and let them copy the URL to download the file without using/sending the form.
我想要实现的是,在提交时,用户在同一页面上下载PDF。我需要这样做以避免转到其他页面并让他们复制URL以下载文件而不使用/发送表单。
The actual behavior of the form is on submit sends the user to http://crm.zoho.com/crm/WebToLeadForm
and the loads back the page http://www.example.com/sucess-page
which is in a input value. This page is different from where the user sents the form.
表单的实际行为是在提交时将用户发送到http://crm.zoho.com/crm/WebToLeadForm并加载回页面http://www.example.com/sucess-page这是一个输入值。此页面与用户发布表单的位置不同。
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 the PDF on same page (I previously added this to htaccess: AddType application/octet-stream .pdf
) but then the form doesn't send the user info to the zoho crm management.
它可以在同一页面上下载PDF(我以前将其添加到htaccess:AddType application / octet-stream .pdf)但是表单不会将用户信息发送到zoho crm管理。
Any idea how to achieve this? Maybe jQuery alternative?
知道怎么做到这一点?也许jQuery替代?
1 个解决方案
#1
Post the form to the same page. Then in your PHP code, check if the form has been submitted. If it has, POST the same data to the crm page using cURL and then echo the PDF link.
将表单发布到同一页面。然后在PHP代码中,检查表单是否已提交。如果有,请使用cURL将相同数据发布到crm页面,然后回显PDF链接。
Example:
<form method="post" action="?">
...
</form>
And then to check if the form has been submitted...
然后检查表单是否已提交...
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
curlPostFunction();
echo "<a href='http://example.com/example.pdf'>Click to download</a>";
}
Read this link for more info on how to create a function to POST using cURL: cURL Post
阅读此链接以获取有关如何使用cURL创建函数以进行POST的更多信息:cURL Post
Note that this is just a basic example -- your code should include more checks based on how secure you want your implementation to be.
请注意,这只是一个基本示例 - 您的代码应根据您希望实现的安全性来包含更多检查。
#1
Post the form to the same page. Then in your PHP code, check if the form has been submitted. If it has, POST the same data to the crm page using cURL and then echo the PDF link.
将表单发布到同一页面。然后在PHP代码中,检查表单是否已提交。如果有,请使用cURL将相同数据发布到crm页面,然后回显PDF链接。
Example:
<form method="post" action="?">
...
</form>
And then to check if the form has been submitted...
然后检查表单是否已提交...
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
curlPostFunction();
echo "<a href='http://example.com/example.pdf'>Click to download</a>";
}
Read this link for more info on how to create a function to POST using cURL: cURL Post
阅读此链接以获取有关如何使用cURL创建函数以进行POST的更多信息:cURL Post
Note that this is just a basic example -- your code should include more checks based on how secure you want your implementation to be.
请注意,这只是一个基本示例 - 您的代码应根据您希望实现的安全性来包含更多检查。