This one is just posted mainly for a friend. He did not understand how to process data differently depending on the submit button clicked, only using ONE HTML FORM. Many people would end up making multiple forms on one or many pages to solve this, which can get rather messy or annoying.
There is a simple way to handle this though using PHP. Take this example:
<input name="button1" type="submit" value="You hit button 1" /> <input name="button2" type="submit" value="You hit button 2" /> <input name="button3" type="submit" value="You hit button 3" /> <?php // check which button was clicked if ($_POST['button1'] { echo "Button one clicked!"; } else if ($_POST['button2']) { echo "Button two clicked!" } else if ($_POST['button3']) { echo "Button three clicked!"; } ?> |
You can see the above in action HERE! As you see, it is a SIMPLE process that will recognize what button you click with very little coding. Using this method, you can process data differently in one simple form! Easy!
In the next few days I’ll probably be working on a small login system that Leigh, a friend of mine requested too. If you also wish for any help/ideas feel free to leave a post or comment and I can normally whip up something within a day or two if it’s a small thing.
Related posts:
sending...
I have no website at present but i am currently in the process of learning and creating a gaming website that interacts with a client to server based game (sort of like ROK) I was wondering what the best possible way to implement a login system that is used not only for the website but used for the game so that statistics etc can be displayed to a single user and not have seperate logins.
I know this seems vague but im still in the early stages of learning php to server scripting which is sort of invalid because most of it is based through the database not the server of the game. (i believe). any help/ words of wisdom would be fantastic.
Cheers, Chris Page (Verim)
Hey there, I must of missed your comment! Huge apologies for that!
Well, the easiest database to use for this is MYSQL or MSSQL. MySQL is better supported by all platforms, and its’ easy to implement in any language you provide, google will be your friend here for snippits of coding.
Depends on what you want, what alot of people tend to do is grab something like PHPBB3 for a good login base and forums, since most games revolve around that. You’ll need to modify or use the PHPBB3 login system password area.Currently PHPBB3 uses a special salted hash, which you can find in the functions.php file, but it might be better to modify it to a simple SHA1 with a salt if you can’t figure it out. You’d need to modify the login area too.
Make sure when people submit passwords from client -> server, That it pre-encrypts the data before sending it, as sending unencrypted passwords is a big no no. When the game server receives a login request, it checks the MYSQL DB to make sure the encrypted password sent matches the encrypted password in the database, and logs in.
Anyways, on to the database structure… You add your tables to the current database (Lets say the phpbb3 one and expand on it, for your game). Just make sure to link them using there ID column, not there name for speed/processing. There are various ways to go by this though, so just give a quick look online
Hope this helps a bit. Apologies, I really stink at describing things.
Hi Chris,
I came across this article while searching for a dependable approach to submitting multiple forms with a lightbox. Eg.
Item A: (view/edit)
Item B: (hide)
choose: choice 1 | choice 2
Item C: (view/edit)
Part 2: sorry about that …
I’d like to be able to expand/collapse multiple items (but only one open at a time), edit an item’s settings, and submit while remaining in the light box. I’m hoping the expanded item would return a confirmation message but that the user could still edit and submit again. In another variation the submit would both confirm and provide some additional options … it could be acceptable to move to a new screen for this if necessary.
What do you think? Thank you!
Hey there, sorry about the late reply, I am not home at the moment.
Anyways, there are a view ways to go around this. The issue first off is that you need a way for the lightbox not to vanish while you are running around doing things. The first simple way would be to use a IFRAME around the lightbox, and keep a CLOSE button just outside of the IFRAME. This would work, but whenever clicking things, it would refresh the lightbox area. This works for simplistic, but it’s no where nice.
The second idea is to use a bit of javascript/css to do your bidding. CSS has a style called ‘display:hidden’ which hides anything in it. What you would do is have everything load on the page, and hide certain areas of it. You would then use javascript to edit the display:hidden to display:block, where it will become visible. You can get fancy and make it hide everything else in a simple function, etc. I can show you an example here: http://chrisvall.com/examples/ShowHide/. It’s no where near for dynamic use, (aka you need to edit it so it can handle one or many view/edits) but it’s a simple example on how hide/show works. This ‘should’ work very nicely, but I believe you may need to still wrap it in a IFRAME so that hitting submit doesn’t refresh the whole page, unless your lightbox supports it. This probably will be enough, just style the IFRAME to have no border/etc, and people won’t even notice it. Javascript can also change the text of certain ID/CLASS elements, google that one and you can simply add it if you want for example ‘Edit’ to become ‘Editing…’ or Show/Hide.
The third/best option is using AJAX. I cant go into details with this right now, but it would be far the best option because AJAX supports awesome ways to submit/edit with nice smooth transitions, and no need for any IFRAMES etc. It’s pretty advanced though but just google around for it
Hope this helps slightly!
Play infomriavte for me, Mr. internet writer.
XI39gt http://wnbUj5n0mXqpcvm27Hms.biz
I study here Little Loli >:-)
US dollars Pretee Models Bikini
06553
Hiya! I just want to give an enormous thumbs up for the nice data you’ve got here on this post. I shall be coming back to your blog for extra soon.
Nice article. I myself write for video games and find it very fulfilling. It’s also great to let go with a tank or tactical nuke once in a while.
Finally! Been trying to figure out how to make it work.
Thanks for the help!
Hello.
I tried testing your script here, but I ran into a couple of problems.
1. It’s missing parentheses and semicolon.s
(revised script)
hmmm. the revised script didn’t appear on my last comment… well, just wanted to let you know you have a couple of typos.
Your web site scrolls in my iPhone, it hurts my eyes, that’s all I’ve got to say
I’m a trainee http://ocafiilemy.de.tl naked bbs ru Damn i love it when she moans and smile when she is getting her tight pussy fucked.How I would love to get some action with her!!!
Could you send me an application form? http://ynulofoti.de.tl nymphet lol tgp Why does the cameraman keep filming this guy? I think this guy might be the creepiest, ugliest guy in any movie anywhere. She must be a great actress. Poor girl!
How much does the job pay? http://gepykecoaqu.de.tl bbs petite model nudes I seriously doubt I’ll ever tire of watching this clip. Cherokee rocks my world. Such the perfect fuck thing.