I have a taxonomy called "Interest". Also I have added a field called "I_am_interested_in" in the profile2 as term reference to the taxonomy "Interest". Then I created a content type called "Profession" which also has a field term reference to the taxonomy "Interest".
Now I want to have an image link right next to the every content title of the content type Profession. When an authenticated user clicks on the link, the taxonomy term associated with the content should be added to the user's "I_am_interested_in" field.
What I did: I have an ajax in page.tpl.php(attached) file in such a way that when a user clicks on the link, it goes to the a new page called ajaxcall.php(attached). Ajaxcall.php does all the database operation with a new db connection.
But I know this approach is not a proper way to do(though it works functionality wise). Please suggest whether I should create a module for this or whatever that is proper. How do I start with creating module for this?
Thanks in advance!
Active
Code