View Single Post
Old 12-15-2012, 07:51 PM   PM User | #2
AndrewGSW
Senior Coder

 
Join Date: Apr 2011
Location: London, England
Posts: 2,120
Thanks: 15
Thanked 354 Times in 353 Posts
AndrewGSW will become famous soon enough
Well, in outline, if you had a checkbox next to the article
Code:
<input type="checkbox" name="subscribe">
you could use its onclick event:
Code:
if (this.checked) {
    // send ajax request with somepage.php?art=idnumber&subs=1
    // and possibly include the userid
} else {
    // send ajax request with somepage.php?art=idnumber&subs=0
}
then somepage.php could:
PHP Code:
<?php
if (isset($_GET['subs']) && !empty($_GET['subs'])) {
    
$subs = (int) $_GET['subs'];
    if (
$subs == 1) {
        
// check and sanitize the userID and articleID
        // execute SQL to insert userID and articleID
    
} else {
        
// check and sanitize the userID and articleID
        // execute SQL to delete userID and articleID
    
}
}
?>
Of course, this assumes that you are using PHP.
__________________
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
Validate your HTML and CSS

Last edited by AndrewGSW; 12-15-2012 at 07:53 PM..
AndrewGSW is offline   Reply With Quote