How to handle Yes/No on webpage

I am adding a feature on my website for Members to add (other Members as) “Friends”.

The way I envision it working, is the person would click on the “Request Friendship” link in that person’s Member Profile, and then be taken to a confirmation page which asks…

You have requested DoubleDee to be your friend.

Would you still like to send this request?

------------------------		-----------
| Request Friendship |		| Cancel |
------------------------		-----------

If the person clicks on the “Request Friendship” then I need to fire off a whole bunch of PHP behind this page to do things like…

  • INSERT record in Friends table
  • EMAIL person

and so on…

I am wondering if I should handle all of this behind an HTML Form, or if there is some way to put “Command Buttons” on a web page and have them trigger actions behind-the-scenes?!

Hope that makes sense?!



Maybe I don’t understand the question properly but why not execute all the code required to actually send the request when the user clicks the “Request Friendship” button?

You’re asking a question of my question?!

I am asking if you can have BUTTONS that do stuff (e.g. execute code) on a Web Page that is NOT a Web Form…

In the past I have always had a Form that was “submitted” and when that happened, then I execute PHP code.

In a way, my example could be construed as a Form because it has a “submit” type button on it. (It just doesn’t have a bunch of Form Fields like you’d usually see.)


Thats what I thought you were asking. The answer to that question is yes but it can be tricky. :slight_smile:

So it sounds like I should use a Form instead…


Yes, that would be a bit easier to set up.