HTML :
<a href="/profile.php?user={$username}&action_request="friend_request">
Friend request
</a>
PHP :
if(isset($_GET['user']) && isset($_GET['action_request'])) {
if(strcmp($_GET['action_request'],"friend_request") == 0) {
insert_friendship($id_user1,$id_user2);
}
}
and the function for insert is :
//sql string
if(sql_insert()) {
return "Friendship request sent!";
} else {
return "Friendship request failed!"; }
P.S I am using smarty engine for templating.
How do i take the url from <a>
tag with ajax and send it to the php page to call the function then ajax to wait for the respond and send it to the html.