Click here to Skip to main content
15,891,597 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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>
Posted
Updated 6-Mar-11 23:13pm
v3

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.
 
Share this answer
 
Comments
vicky87 1-Mar-11 14:44pm    
here is the link to form which i am using http://mwac87.hostzi.com/zoho.php which is just adding data to ZOHO CRM only ...

ob_start();
include(dirname(__FILE__).'/res/exemple03.php');
$content = ob_get_clean();

// conversion HTML => PDF
require_once(dirname(__FILE__).'/../html2pdf.class.php');
try
{
$html2pdf = new HTML2PDF('P','A4', 'fr', false, 'ISO-8859-15', 3);
$html2pdf->pdf->SetDisplayMode('fullpage');
$html2pdf->writeHTML($content, isset($_GET['vuehtml']));
$html2pdf->Output('exemple03.pdf');
}
catch(HTML2PDF_exception $e) { echo $e; }

this is code which i am using to create pdf...
Sergey Alexandrovich Kryukov 1-Mar-11 14:52pm    
Correct, my 5.
--SA
vicky87 1-Mar-11 14:54pm    
to make things clear i have one form file ....which collect data ...and add to ZOHO right now ...
and a file name proposal which have few blanks which going to be fills by given data by user and create a PDF and email him....
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
 
Share this answer
 
Comments
vicky87 1-Mar-11 14:23pm    
is there any example ..to follow ...
Albin Abel 1-Mar-11 14:42pm    
Will provide examples, if I get time to do homework. But another thing you can do. As Yusuf said collect all the data in your form posting. Do whatever and if need to send data to another webservice or anything like ZOHO....send those data usin CUrl posting from PHP
Sergey Alexandrovich Kryukov 1-Mar-11 14:53pm    
You're right, my 5.
--SA
vicky87 1-Mar-11 15:38pm    
i am not expert in php ...so i need few examples how to do it .. i have to do it ASAP ..this is the last thing in my project...and i am trying to do ASAP ..so i can closed this thing ...so plz need help ..
vicky87 5-Mar-11 6:44am    
as you as i have done it using AJAX ...but it is not sending vales to php file and not creating pdf..

AJAX code



<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.onreadystatechange = 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>

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900