Add data in database through a link

-1

I gave a quick search but did not find it, so I'm posting here. I want to get the following SQL code:

INSERT INTO 'rooms' ('id', 'roomtype', 'caption', 'owner', 'description', 'category', 'state', 'users_now', 'users_max', 'model_name', 'public_ccts', 'score', 'tags', 'icon_bg', 'icon_fg', 'icon_items', 'password', 'wallpaper', 'floor', 'landscape', 'allow_pets', 'allow_pets_eat', 'allow_walkthrough', 'allow_hidewall', 'wallthick', 'floorthick', 'achievement') VALUES
('', 'private', '', '', 'Novo modelo de quarto', '1', 'locked', '0', '100', 'model_recep2', 'hh_room_nlobby2', '538', '', '12', '0', '', '', '0.0', '407', '0.0', '0', '0', '1', '1', '-2', '-2', '0');

What I saw on the Internet should be for <a href=.......>inserir</a> , I even created a page with hash js and this SQL above, but I do not know how to do that so when clicking < in> link to run such a code. Thanks!

    
asked by anonymous 19.09.2014 / 22:26

1 answer

2

There are several ways to do this, one is like the our colleague put : simply point the href of your link to the PHP that does this insert .

Another way is to run asynchronously using JavaScript AJAX.

You can easily do this by using the .get or % jQuery% method:

fucntion incluir(){
    $.post( "ajax/incluir.php", function( data ) {
      console.log(data);
    });
}

This parameter is the return of the file .post , it can be a .php .

Remember to call this method echo 'salvo com sucesso'; of JavaScript in the event (may be incluir ) of your element (in your case a link) but could be a button too.

    
20.09.2014 / 03:52