PHP forms can be very easily integrated into any HTML page with the use of Ajax.
This method is suitable for any CMS: Wordpress, Joomla, Drupal or other.
No additional plugin is usually required, just add Javascript code in the body of your page.
Here's how it works:
Add phpformbuilder folder at the root of your project.
Your directory structure should be similar to this :
PHP Form Builder's package includes the Form Builder itself, the documentation and all the templates.
Documentation and Templates are available online at https://www.phpformbuilder.pro/.
There's no need to upload them on your production server.
More details about folders, files and required files on production server here: ../index.html#package-structure
Create a new directory named ajax-forms at the root of your project.
You can choose another name and another location, in which case you'll just have to change the URL called with Ajax in step 4.
Create your form in a new PHP file and save it into your /ajax-forms folder.
<div id="ajax-form"></div>
<!-- Ajax form loader -->
<script type="text/javascript">
var $head= document.getElementsByTagName('head')[0],
target = '#ajax-form';
var loadData = function(data, index) {
if (index <= $(data).length) {
var that = $(data).get(index);
if ($(that).is('script')) {
// output script
var script = document.createElement('script');
script.type = 'text/javascript';
if (that.src != '') {
script.src = that.src;
script.onload = function() {
loadData(data, index + 1);
};
$head.append(script);
} else {
script.text = that.text;
$('body').append(script);
loadData(data, index + 1);
}
} else {
// output form html
$(target).append($(that));
loadData(data, index + 1);
}
} else {
$.holdReady(false);
}
};
$(document).ready(function() {
$.ajax({
url: 'ajax-forms/contact-form-1.php',
type: 'GET'
}).done(function(data) {
$.holdReady(true);
loadData(data, 0);
}).fail(function(data, statut, error) {
console.log(error);
});
});
</script>