将数据发送到php文件不起作用... [英] sending data to onthe php file not working...

查看:94
本文介绍了将数据发送到php文件不起作用...的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨 我已经使用ZOHO表单生成器创建了WebToLeadForm ..并且我正在使用html2PDF创建PDF,并且效果很好...
我正在从表单收集数据并将其发送到main.php,并尝试生成pdf和电子邮件到用户邮件地址..
问题是当我调用该函数时,无法将数据发送到main.php并且不生成pdf ...

代码在下面给出..

<<pre lang="xml">div id="crmWebToEntityForm" align="center">
    <meta content="text/html;charset = UTF-8" http-equiv="content-type">
    <form accept-charset="UTF-8" action="https://crm.zoho.com/crm/WebToLeadForm" method="POST" onsubmit="javascript:document.charset=&quot;UTF-8&quot;;">
        <table border="0" cellpadding="5" cellspacing="0" style="border-top: 2px solid #999999; border-bottom: 1px solid #999999; background-color: #ffffff;" width="480">
            <input name="xnQsjsdp" type="hidden" value="R8GmtDQunn4$" />
            <input name="xmIwtLD" type="hidden" value="0KkcJmB-M0IJB3CFzjZrv2-*B6-MHnNR" />
            <input name="actionType" type="hidden" value="TGVhZHM=" />
            <input name="returnURL" type="hidden" value="http://mwac87.hostzi.com" />
            <br>
            <tr>
                <td align="left" colspan="2" style="background-color: #f5f5f5; border-bottom: 2px dotted #dadada; color: #000000; font-family: sans-serif; font-size: 14px;">
                <strong>Web Form</strong></td>
            </tr>
            <tr>
                <td align="right" nowrap style="font-family: sans-serif; font-size: 12px; font-weight: bold" width="25%">
                Company&nbsp;&nbsp; :</td>
                <td width="75%">
                <input maxlength="100" name="Company" type="text" /> </td>
            </tr>
            <tr>
                <td align="right" nowrap style="font-family: sans-serif; font-size: 12px; font-weight: bold" width="25%">
                Last Name&nbsp;&nbsp; :</td>
                <td width="75%">
                <input maxlength="80" name="Last Name" type="text" /> </td>
            </tr>
            <tr>
                <td align="right" nowrap style="font-family: sans-serif; font-size: 12px; font-weight: bold" width="25%">
                Email&nbsp;&nbsp; :</td>
                <td width="75%">
                <input maxlength="100" name="Email" type="text" /> </td>
            </tr>
            <tr>
                <td align="right" nowrap style="font-family: sans-serif; font-size: 12px; font-weight: bold" width="25%">
                No of Employees&nbsp;&nbsp; :</td>
                <td width="75%">
                <input maxlength="16" name="No of Employees" type="text" /> </td>
            </tr>
            <tr>
                <td align="center" colspan="2" style="background-color: #eaeaea">
                <input name="save" onclick=''ajaxFunction();'' type="submit" value="Save" />&nbsp;&nbsp;&nbsp;&nbsp;
                <input name="reset" type="reset" value="Reset" /> </td>
            </tr>
        </table>
    </form>
</div>



<script> function ajaxFunction(){ var ajaxRequest; // The variable that makes Ajax possible! try{ // Opera 8.0+, Firefox, Safari ajaxRequest = new XMLHttpRequest(); } catch (e){ // Internet Explorer Browsers try{ ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try{ ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e){ // Something went wrong alert("Your browser broke!"); return false; } } } // Create a function that will receive data sent from the server ajaxRequest. önreadystatechange = function(){ if(ajaxRequest.readyState == 4){ document.myForm.time.value = ajaxRequest.responseText; } } var Company = document.getElementById(''Company''); var LastName = document.getElementById(''LastName''); var Email = document.getElementById(''Email''); var NoofEmployees = document.getElementById(''NoofEmployees''); var queryString = "?Company=" + Company + "&Email=" + Email + "&NoofEmployees=" + NoofEmployees ; alert(queryString); ajaxRequest.open("GET", "main.php" + queryString, true); ajaxRequest.send(null); } </script>

解决方案

"/> <输入名称="xmIwtLD"类型=隐藏" value ="0KkcJmB-M0IJB3CFzjZrv2- * B6-MHnNR"/> <输入名称="actionType"类型=隐藏" value ="TGVhZHM ="/> <输入名称="returnURL"类型=隐藏" value ="http://mwac87.hostzi.com"/> < br> < tr> < td align ="left" colspan ="2" style ="background-color:#f5f5f5; border-bottom:2px点缀#dadada; color:#000000; font-family:sans-serif; font-size:14px ;> < strong> Web表单</strong></td> </tr> < tr> < td align ="right" nowrap style ="font-family:sans-serif; font-size:12px; font-weight:粗体" width ="25%"> 公司:</td> < td width ="75%"> < input maxlength ="100" name ="Company" type ="text"/> </td> </tr> < tr> < td align ="right" nowrap style ="font-family:sans-serif; font-size:12px; font-weight:粗体" width ="25%"> 姓氏:</td> < td width ="75%"> < input maxlength ="80" name =姓氏" type ="text"/> </td> </tr> < tr> < td align ="right" nowrap style ="font-family:sans-serif; font-size:12px; font-weight:粗体" width ="25%"> 电子邮件:</td> < td width ="75%"> < input maxlength ="100" name =电子邮件" type ="text"/> </td> </tr> < tr> < td align ="right" nowrap style ="font-family:sans-serif; font-size:12px; font-weight:粗体" width ="25%"> 员工人数:</td> < td width ="75%"> < input maxlength ="16" name =员工人数" type ="text"/> </td> </tr> < tr> < td align ="center" colspan ="2" style ="background-color:#eaeaea"> <输入名称=保存" onclick =''ajaxFunction();''type ="submit" value =保存"/>& nbsp;& nbsp;& nbsp;& nbsp; <输入名称=重置" type =重置"值=重置"/> </td> </tr> </table> </form> </div>



<script> function ajaxFunction(){ var ajaxRequest; // The variable that makes Ajax possible! try{ // Opera 8.0+, Firefox, Safari ajaxRequest = new XMLHttpRequest(); } catch (e){ // Internet Explorer Browsers try{ ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try{ ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e){ // Something went wrong alert("Your browser broke!"); return false; } } } // Create a function that will receive data sent from the server ajaxRequest. önreadystatechange = function(){ if(ajaxRequest.readyState == 4){ document.myForm.time.value = ajaxRequest.responseText; } } var Company = document.getElementById(''Company''); var LastName = document.getElementById(''LastName''); var Email = document.getElementById(''Email''); var NoofEmployees = document.getElementById(''NoofEmployees''); var queryString = "?Company=" + Company + "&Email=" + Email + "&NoofEmployees=" + NoofEmployees ; alert(queryString); ajaxRequest.open("GET", "main.php" + queryString, true); ajaxRequest.send(null); } </script>


您有点困惑.您无需同时发布到您的页面和ZOHO.您只需要发布到您的页面,而不是ZOHO.首先发布到您的页面,然后处理您要在页面中处理的所有内容.没事的时候,您redirect 去ZOHO.

这样做有几种方法,在不了解您的代码的情况下,我无法给您具体的建议.


我不认为这是正常的方法.在第一种形式中,如何在提交按钮的onclick事件上使用javascript.通过使用Ajax的javascript联系人html2PDF.

由于发布了一种表单,因此您无法控制网站上的表单(一旦发布,浏览器就准备好接收响应,而不必等待发布另一种表单),就无法发布另一种表单,即使是从javascript


hi i have created WebToLeadForm using ZOHO form generator ..and i am using html2PDF to create PDFs and which is working fine ...
i am collecting data from form and sending it to main.php and trying to generate pdf and email to user mail address ..
problem is can''t send data to main.php and not generating pdf when i call the function...

code in given below..

<<pre lang="xml">div id="crmWebToEntityForm" align="center">
    <meta content="text/html;charset = UTF-8" http-equiv="content-type">
    <form accept-charset="UTF-8" action="https://crm.zoho.com/crm/WebToLeadForm" method="POST" onsubmit="javascript:document.charset=&quot;UTF-8&quot;;">
        <table border="0" cellpadding="5" cellspacing="0" style="border-top: 2px solid #999999; border-bottom: 1px solid #999999; background-color: #ffffff;" width="480">
            <input name="xnQsjsdp" type="hidden" value="R8GmtDQunn4$" />
            <input name="xmIwtLD" type="hidden" value="0KkcJmB-M0IJB3CFzjZrv2-*B6-MHnNR" />
            <input name="actionType" type="hidden" value="TGVhZHM=" />
            <input name="returnURL" type="hidden" value="http://mwac87.hostzi.com" />
            <br>
            <tr>
                <td align="left" colspan="2" style="background-color: #f5f5f5; border-bottom: 2px dotted #dadada; color: #000000; font-family: sans-serif; font-size: 14px;">
                <strong>Web Form</strong></td>
            </tr>
            <tr>
                <td align="right" nowrap style="font-family: sans-serif; font-size: 12px; font-weight: bold" width="25%">
                Company&nbsp;&nbsp; :</td>
                <td width="75%">
                <input maxlength="100" name="Company" type="text" /> </td>
            </tr>
            <tr>
                <td align="right" nowrap style="font-family: sans-serif; font-size: 12px; font-weight: bold" width="25%">
                Last Name&nbsp;&nbsp; :</td>
                <td width="75%">
                <input maxlength="80" name="Last Name" type="text" /> </td>
            </tr>
            <tr>
                <td align="right" nowrap style="font-family: sans-serif; font-size: 12px; font-weight: bold" width="25%">
                Email&nbsp;&nbsp; :</td>
                <td width="75%">
                <input maxlength="100" name="Email" type="text" /> </td>
            </tr>
            <tr>
                <td align="right" nowrap style="font-family: sans-serif; font-size: 12px; font-weight: bold" width="25%">
                No of Employees&nbsp;&nbsp; :</td>
                <td width="75%">
                <input maxlength="16" name="No of Employees" type="text" /> </td>
            </tr>
            <tr>
                <td align="center" colspan="2" style="background-color: #eaeaea">
                <input name="save" onclick=''ajaxFunction();'' type="submit" value="Save" />&nbsp;&nbsp;&nbsp;&nbsp;
                <input name="reset" type="reset" value="Reset" /> </td>
            </tr>
        </table>
    </form>
</div>



<script> function ajaxFunction(){ var ajaxRequest; // The variable that makes Ajax possible! try{ // Opera 8.0+, Firefox, Safari ajaxRequest = new XMLHttpRequest(); } catch (e){ // Internet Explorer Browsers try{ ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try{ ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e){ // Something went wrong alert("Your browser broke!"); return false; } } } // Create a function that will receive data sent from the server ajaxRequest. önreadystatechange = function(){ if(ajaxRequest.readyState == 4){ document.myForm.time.value = ajaxRequest.responseText; } } var Company = document.getElementById(''Company''); var LastName = document.getElementById(''LastName''); var Email = document.getElementById(''Email''); var NoofEmployees = document.getElementById(''NoofEmployees''); var queryString = "?Company=" + Company + "&Email=" + Email + "&NoofEmployees=" + NoofEmployees ; alert(queryString); ajaxRequest.open("GET", "main.php" + queryString, true); ajaxRequest.send(null); } </script>

解决方案

" /> <input name="xmIwtLD" type="hidden" value="0KkcJmB-M0IJB3CFzjZrv2-*B6-MHnNR" /> <input name="actionType" type="hidden" value="TGVhZHM=" /> <input name="returnURL" type="hidden" value="http://mwac87.hostzi.com" /> <br> <tr> <td align="left" colspan="2" style="background-color: #f5f5f5; border-bottom: 2px dotted #dadada; color: #000000; font-family: sans-serif; font-size: 14px;"> <strong>Web Form</strong></td> </tr> <tr> <td align="right" nowrap style="font-family: sans-serif; font-size: 12px; font-weight: bold" width="25%"> Company&nbsp;&nbsp; :</td> <td width="75%"> <input maxlength="100" name="Company" type="text" /> </td> </tr> <tr> <td align="right" nowrap style="font-family: sans-serif; font-size: 12px; font-weight: bold" width="25%"> Last Name&nbsp;&nbsp; :</td> <td width="75%"> <input maxlength="80" name="Last Name" type="text" /> </td> </tr> <tr> <td align="right" nowrap style="font-family: sans-serif; font-size: 12px; font-weight: bold" width="25%"> Email&nbsp;&nbsp; :</td> <td width="75%"> <input maxlength="100" name="Email" type="text" /> </td> </tr> <tr> <td align="right" nowrap style="font-family: sans-serif; font-size: 12px; font-weight: bold" width="25%"> No of Employees&nbsp;&nbsp; :</td> <td width="75%"> <input maxlength="16" name="No of Employees" type="text" /> </td> </tr> <tr> <td align="center" colspan="2" style="background-color: #eaeaea"> <input name="save" onclick=''ajaxFunction();'' type="submit" value="Save" />&nbsp;&nbsp;&nbsp;&nbsp; <input name="reset" type="reset" value="Reset" /> </td> </tr> </table> </form> </div>



<script> function ajaxFunction(){ var ajaxRequest; // The variable that makes Ajax possible! try{ // Opera 8.0+, Firefox, Safari ajaxRequest = new XMLHttpRequest(); } catch (e){ // Internet Explorer Browsers try{ ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try{ ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e){ // Something went wrong alert("Your browser broke!"); return false; } } } // Create a function that will receive data sent from the server ajaxRequest. önreadystatechange = function(){ if(ajaxRequest.readyState == 4){ document.myForm.time.value = ajaxRequest.responseText; } } var Company = document.getElementById(''Company''); var LastName = document.getElementById(''LastName''); var Email = document.getElementById(''Email''); var NoofEmployees = document.getElementById(''NoofEmployees''); var queryString = "?Company=" + Company + "&Email=" + Email + "&NoofEmployees=" + NoofEmployees ; alert(queryString); ajaxRequest.open("GET", "main.php" + queryString, true); ajaxRequest.send(null); } </script>


You got a bit confused. you don''t need to post to both your page and ZOHO. You only need to post to your page, not ZOHO. First post to your page, you handle whatever you want to handle in your page. When things are ok, then you redirect to ZOHO.

There are several ways of doing this, I can''t give you specific suggestions with out knowing something about your code.


I don''t think this is the normal way. Any how use a javascript on the onclick event of the submit button in the first form. From the javascript contact html2PDF using Ajax.

Because one form posted then you don''t have control (once posted the browser is ready to receive the response, not wait to post another one) on the website to post another form, even from the javascript


这篇关于将数据发送到php文件不起作用...的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆