Been a long time since I've posted...

I plan on redoing a CMS I built using PHP/MySQL.

This time around I want to employ jQuery and AJAX.

Just a simple question to start....

It was once recommeded to me that I reference a separate php file that contains all of my php custom functions. I use a lot of the same functions in different pages. It makes sense.

When submitting a php form, I plan on having referencing a javascript file that contains code that loops through all the form elements and formats the entered values as JSON.

The php form will look something like this:

Code:
<form action = "ajax/contact-form.php" method = "post" class = "ajax">
form input fields and submit button here
</form>
Any form in my CMS that has class 'ajax' will be looped and formatted as JSON via my ajax file.

My javascript page then calls the jQuery post method and sumbits the data to mySql db. Kinda like this:

Code:
$('form.ajax').on('submit', function() {

var that = $(this),
 url = that.attr('action'),
type = that.attr('method'),
data = {};

...
...

$.ajax({
url: 
type: post
data: JSON data from above JS;

}

});
The js uses the form action to determine what ajax php page to process. That php page (ajax/contact-form.php) has the command to insert into my db.

The snippet of code above is NOT MINE. I have been studying ajax and jquery. It is example code.

I understand how it works I feel, but how can I have multiple insert functions all in ONE php page? Let's say I have another form on a separate page...

I'd want the php method to reference the same ajax php page, but I'd want it to use a different INSERT statement to save it properly in that page. I'm guessing that's easiest... that way I don't have tons of separate php files that are running my insert statements per the form that's submitted.

I really hope I made some sense here. If not, I'll try to explain more...