views:

1016

answers:

1

I have a server driven site using php and js. One section displays all photos that our users have uploaded, and an administrator then decides which photos to keep for final presentation. Most of the site uses jquery for inplace edits, yet this task has me stumped. I want to insert a row into a MySQL database table that copies the URL of the photo and other associated information with the click of a checkbox ...NO SUBMIT button.

I have all the info I need generated in a foreach (glob($dir)) and beside each photo generated I can place the checkbox.

+2  A: 
$('checkbox selectors here').bind('click', function() {
    $.ajax({
        type: 'POST',
        url: url/to/backend.page,
        data: {dictionary of data},
        etc etc
    });
);

On the backend page, just handle the POST request and insert the appropriate MySQL records.

Stuart Childs
make sure to include some kind of token in the data, otherwise someone could use the action URL as an image source, which is then loaded by an admin who hits the page and inadvertently causes the action.
yaauie