php button submit

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ssettlemyre
Forum Newbie
Posts: 3
Joined: Wed Sep 27, 2006 12:31 pm

php button submit

Post by ssettlemyre »

do <button> style submits get posted with form submits? I dont think they do.

Typically I use submit forms with <input> submits then switch based on the $_POST key string to determine which button was pushed.

Code: Select all

<?
if($_POST['login']){
   // do login stuff
}
?>

<input type="submit" name="login" value="login">
but i'd like to do the same with <button> type submits (can make them a lot fancier)
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post by Luke »

is there a question in there somewhere?? :?
ssettlemyre
Forum Newbie
Posts: 3
Joined: Wed Sep 27, 2006 12:31 pm

Post by ssettlemyre »

do <button> style submits get posted with form submits?
isn't that a question?

Even though I answered it myself, I was asking if anyone knows otherwise.
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Post by onion2k »

No they don't because a 'button' input element isn't a submitted form field. You can use JavaScript to update a hidden value and the submit the form on a click of a button though.

I'm curious though, what can you do to a 'button' that you can't do to a 'submit'?
ssettlemyre
Forum Newbie
Posts: 3
Joined: Wed Sep 27, 2006 12:31 pm

Post by ssettlemyre »

you can have any code you want inside a <button></button> tag. Images, tables, etc...

and it's helpful because you can just reference it in css instead of using <input type="submit" class="blah">
User avatar
panic!
Forum Regular
Posts: 516
Joined: Mon Jul 31, 2006 7:59 am
Location: Brighton, UK

Post by panic! »

or you could use a hidden

<input type="hidden" name="submitted" value="yes"/>

or you could just write

if($_POST){




}
Post Reply