I have a follow button that when I press on it store into follow table followerid and followingid and turned into unfollow
and when I press on unfollow delete them from follow table
I used JQuery for this
but when I press on the button it turned into unfollow but does not store any data in the data base can you help me find the error please
JQuery
function change( el )
{
var input= $('#followingid').val();
var input2=$('#followerid').val();
if ( el.value == "Follow" )
{
$.get("follow_button.php",{following_id:'input',follower_id:'input2'});
el.value = "Unfollow";
}
else
{
$.get("unfollow_button.php",{following_id:'input',follower_id:'input2'});
el.value = "Follow";
}
}
and this is the follow button
<form action="" method="post" name="f1">
<input type="button" value="<?php
$sql="SELECT * FROM follow WHERE followerid=$id and followingid=$projectid";
$q=mysql_query($sql) or die (mysql_error());
if($num=mysql_num_rows($q))
echo 'Unfollow';
else
echo 'Follow';
?>" onclick="return change(this);" />
</form>
and this is follow_button.php
page
<?php
$followerid=$_GET['follower_id'];
$followingid=$_GET['following_id'];
$sql2="INSERT INTO follow (followerid,followingid) VALUES($followerid,$followingid)";
$q2=mysql_query($sql2) or die(mysql_error());
?>
unfollow_button.php
page
<?php
$follower_id=$_GET['followerid'];
$following_id=$_GET['followingid'];
$sql2="DELETE FROM follow WHERE followingid=$following_id and followerid=$follower_id";
$q2=mysql_query($sql2);
?>
I review my code several times but I could't find the error ,,I hope you can find the problem thanx ...