Finish Final Stage of Social Networking Button

Hi,

I am trying to complete a button which allows someone to follow somone else. It is designed to be a social networking button. I could get the button to work whever the page is loaded which is highly undersirable but I cant make it work when the button is pressed.

I am really stuck on this, does anyone have any suggestions on what I can try to get it to work please.

[code]<?php

$followerid = intval($_SESSION[‘userID’]);
$profileid = intval($row[‘id’]);

if(isset($_POST[‘followbutton’]) && $_POST[‘followbutton’] == ‘true’){

if($profileid =  $followerid) {
    $errors['profileid'] = "This is a test error.";
}

if(!$errors){
//Validation of input vars passed, attempt to run query
//Force vars to be ints to be safe for query statement

	    $followerid = intval($_SESSION['userID']);
    $profileid  = intval($row['id']);

    $query = "INSERT INTO `follow` (`user_id`, `follow_user_id`) VALUES ('{$profileid}', '{$followerid}')";
    $result = mysql_query($query);

	
    if (!$result)
    {
            $errors[] = "Query: {$query}<br>Error: " . mysql_error();

    }
}	
}

?>[/code]

Sorry I’m not sure what the problem is. The code appears to do what you want, only executing when $_POST[‘followbutton’] is pressed?

Hi,

I have the above. It only use to work when someone visited the page which meant that someone can follow someine just by visiting their page which is highly undersirable. However I cant make it work so that someone will only follow someone when they click the follow button.

Sponsor our Newsletter | Privacy Policy | Terms of Service