This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

KosGig
KosGig

Hello all, i want to create a contact form with a jQuery Form Validation plugin and i want to use a PHP function for sending emails.

I want to do this:

$(document).ready(function() {
....
 // Send all form data to back-end
                    $.ajax({
                        url: 'submit.php',
                        type: 'POST',
                        data: $form.serialize(),
                        success: function(response) {
....

Now, i need to put a valid url for the PHP Function ( url: 'submit.php'). I created a file with .htm extension in partials and inside the code block i put the PHP function.

How can i pass the .htm file to url (url: 'submit.htm ')? I tried with many ways but the result is a 404 Not Found Error.

Last updated

alxy
alxy

Use the AJAX Framework instead.

The handler refers to Component methods, from there you can send your mail. I can recommend to read the entire documentation page, its has some nice exaples of what is possible.

Last updated

philipptempel
philipptempel

As @alxy said, read the docs. There is no way for you to access a partial through a URI directly. The only thing you could do is create a CMS page that will be on the receiving end of your request. However, you will then get the overhead of loading the whole framework with every request. Therefore, it's the best to read through the docs. Also have a look at the demo component "Calculator" which is installed with the default October site (found under menu "AJAX Framework"). What you want to achieve is similar to this: you could copy the code and adjust it to your needs - just add the right fields, validation, and then use October's Mail Service which is inferior over PHP's mail() function.

KosGig
KosGig

Thank you very much for your answers... I am going to read the documentation & practice and i' ll return here when i have the write way to do it.

KosGig
KosGig

As you said, the AJAX Framework helped me to do it. Indeed, it was similar to "Calculator" demo component. I put the PHP Function inside the code block in .htm extension file in Pages and then i used Ajax Framework to call the function.

Last updated

1-5 of 5

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.