doubu4826
doubu4826
2015-02-24 15:20

PHP帮助:在微博中关注系统

  • css
  • php

I'm making a site similar to Instagram. I am very new to php. I created a follow button in the user's profile.

How do you make the follow button disappear when you already followed the user? How do you replace it with unfollow button?

// my php code for following

if (isset($_POST['addfriend'])){


    $fromuser = $user;
    $touser = $username;

    if($fromuser == $username){
        $Msg = "You cannot follow yourself<br/>";
    }
    else
    {
        $getID= mysql_query("SELECT userID FROM user WHERE username='$user'");
        $get_ID_row = mysql_fetch_assoc($getID);
        $ID_db = $get_ID_row['userID'];

        $sql = "insert into following (userID, fromUser, toUser) 
        values ('$ID_db','$fromuser', '$touser')";

        $result = mysql_query($sql);

         $Msg= "Success! <br/>";

    }
}
else{
    //Do nothing
}

//my code for the follow button

                        <form action="<?php $user;?>" method ="POST">
                        <?php echo $Msg; ?>
                        <input type = "submit" name ="addfriend" value = "Follow"/>
                        </form>
  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

2条回答

为你推荐