Hi,
I have made some progress with this. I can now echo all the rows I need and it no longer runs when the page is reloaded however the code no longer works when the button is pressed.
I have tried printing some values but these dont seem to help. Does anyone have any suggestions please on what I can try to get it to work?
Code:
<?php
$followerid = intval($_SESSION['userID']);
$profileid = intval($row['id']);
print_r ($followerid);
print_r ($profileid);
echo '<pre>' . print_r($_SESSION, true) . '</pre>';
echo print_r ($followbutton);
echo '<pre>' . print_r($_POST, true) . '</pre>';
if(isset($_POST['followbutton']) && $_POST['followbutton'] == 'true'){
print_r ($followerid);
print_r ($profileid);
print_r ($_POST['followbutton']);
echo print_r ($followbutton);
echo '<pre>' . print_r($_POST, true) . '</pre>';
echo '<pre>' . print_r($_SESSION, true) . '</pre>';
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();
}
}
}
?>
<?php
print_r ($followerid);
print_r ($profileid);
print_r ($followbutton);
echo print_r ($_POST['followbutton']);
echo '<pre>' . print_r($_POST, true) . '</pre>';
echo print_r ($followbutton);
?>
<?php if($errors['profileid']) print '<div class="invalid">' . $errors['profileid'] . ''; ?>
</div>
<div class="followbuttonbox">
<a href="<?php echo $_SERVER['PHP_SELF']; ?>?ID=<?php echo $profileid; ?>"><img src="/images/follow.png" id="followbutton" /></a>
<input type="hidden" id="followbutton" value="true" />
</div>
Bookmarks