Jump to content

Implement PHP code into Ajax


skter4938

Recommended Posts

Hello. I have this question that I cannot possibly get working.

 

Alright, let me explain. I have a button which is called "bookmark". When that button is clicked, it goes to a page called "bookmark.php" and then executes a peice of code which adds that file to you bookmarks.

 

Now what I want to do is have a image named "bookmark" which will be a little '+' sign. When that image is clicked, the bookmark.php code is executed BUT WITHOUT CHANGING THE PAGE. aka using Ajax.

 

and if that file has already been bookmarked the image will be a little '-' sign.

 

So here is my bookmark.php code:

<?
require_once("include/main.php");
dbconn();
loggedinorreturn();

function bark($msg) {
stdhead();
   stdmsg("w00t!", $msg);
stdfoot();
exit;
}

if (!isset($_GET[file]))
       bark ("Faild ... No file selected");


if ((get_row_count("bookmarks", "WHERE userid=$CURUSER[id] AND fileid = $_GET[file]")) > 0)
       bark("Already bookmarked $_GET[file]");

mysql_query("INSERT INTO bookmarks (userid, fileid) VALUES ($CURUSER[id], $_GET[file])") or sqlerr(__FILE__,__LINE__);

bark ("Successfully bookmarked");



?>

 

and here is the image of the way it goes to the boomark.php page.

asdasws3.png

 

 

the little + sign is the bookmark.php button thing, and the arrow is the download button.

 

-Artem

 

Link to comment
https://forums.phpfreaks.com/topic/44145-implement-php-code-into-ajax/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.