doubledee — 2012-05-10T15:15:17-04:00 — #1
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?!
theraptor — 2012-05-10T15:28:43-04:00 — #2
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?
doubledee — 2012-05-10T15:43:50-04:00 — #3
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.)
theraptor — 2012-05-10T15:48:11-04:00 — #4
Thats what I thought you were asking. The answer to that question is yes but it can be tricky.
doubledee — 2012-05-10T16:27:15-04:00 — #5
So it sounds like I should use a Form instead...
theraptor — 2012-05-10T16:34:22-04:00 — #6
Yes, that would be a bit easier to set up.