I need to create something which is like an Add friend function in my website which works like this:

1) User types in name of the person he wants to search in the search field and clicks enter
2) on the same page, the search result will come out with an "add friend" button beside every name
3) when the user clicks the "add friend" button, he will be brought to another page (or pop up with a message box?) with a text message field to send to the friend, and a submit button to submit the friend request.
4) over at the Friend's page, he will be able to view the add friend request and decide whether to accept or deny the friend request.

How do i go about doing this? any one help or provide me some guide or advice please?

Any help will be appreaciated. Thanks!