Next, on the page of each post has a button to "favor", how can I check if the post has already been tanned and change the name of the button to, for example, "favorited" and if not, by clicking the button would be done, but all in the background, I have very shallow knowledge in javascript, but I know I will need ajax for this. I already mounted a small script in php / mysql that returns a json {"favorite":1}
when the post is already favored or when it is changed to favorited, being its natural state {"favorite":0}
As you can only favor being logged into the site, the user id will be captured by session , and the post id will be sent via the POST >
Ex:
<a href="site.com/post/favoritar">Favoritar</a>