Creating a Follow User mechanism -
I am trying to create a follow-up mechanism, where the user can follow the other. What I am doing, if I try to follow AB, then I insert an email ID against B. Now when A again tries to follow B, an ID is checked against B, if it is proved true, then it redirects and shows that it is already followed but If someone tries to follow someone, then he is added.
The problem now is that the first part is working fine, but if I follow the same person again, then he will be able to re-enter the table.
$ temp = $ _ GET ['temp']; Counter $ temp; Mysql_connect ('localhost', 'root', ''); Mysql_select_db ('reviewed'); $ Query = "Follow follow-follow-user where my_email = '". $ _ Session ['email']. "'"; $ Data = mysql_query ($ query); If (! $ Data) {// Add this check die ('invalid query:'. Mysql_error ()); } If (mysql_num_rows ($ data) & gt; 0) {while ($ line = mysql_fetch_array ($ data)) {$ user = $ row ['follow_user']; If ($ temp === $ user) {header ('location: acc.fp? Success = 1'); $ _SESSION ['message'] = 'Already running'. '; } Other {mysql_connect ('localhost', 'root', ''); Mysql_select_db ('reviewed'); $ Query = "Follow (my_email, follow_user) values ('. $ _ Session [' email '].' ','". $ Temp. "'')"; $ Data = mysql_query ($ query); If (! $ Data) {// Add this check die ('invalid query:'. Mysql_error ()); } "Success" echo; }}} And {mysql_connect ('localhost', 'root', ''); Mysql_select_db ('reviewed'); $ Query = "Follow (my_email, follow_user) values ('. $ _ Session [' email '].' ','". $ Temp. "'')"; $ Data = mysql_query ($ query); If (! $ Data) {// Add this check die ('invalid query:'. Mysql_error ()); } "Success" echo; }
It seems to me that you are adding follow-up records for each user Compared to B, A is the following: I think you might be able to fix it by restricting A along with B in its primary query.
$ query = "Follow follow-up follower where my_email = '". $ _ Session ['email'] "" and follow _username = '". $ Temp"' ';
Then you can remove the loop:
if (mysql_num_rows ($ data)> gt; {header ('location: acc.fp? Success = 1 '); $ _SESSION ['message'] = 'Already running'. '; } Other {mysql_connect ('localhost', 'root', ''); Mysql_select_db ('reviewed'); $ Query = "Follow (my_email, follow_user) values ('. $ _ Session [' email '].' ','". $ Temp. "'')"; $ Data = mysql_query ($ query); If (! $ Data) {// Add this check die ('invalid query:'. Mysql_error ()); } "Success" echo; }
Comments
Post a Comment