RE: [PHP] Very simple forms processing question

From: Date: Mon, 08 Mar 2004 17:47:00 +0000
Subject: RE: [PHP] Very simple forms processing question
Groups: php.general 
Request: Send a blank email to php-general+get-179804@lists.php.net to get a copy of this message
[snip] I want to set up a mailing list on a site, and I want a very simple register/deregister facility. So a text field for the email address, then an [add] button and a [remove] button. Now, what I really want is for both [add] and [remove] to be 'submit' type HTML buttons for the same form, but at the destination script I don't know how to tell which button was pressed, and I've a feeling I should only have one submit button. I can do what I want JavaScript, but can I do it just with PHP? Any clues, or am I not being clear? [/snip] Use this in your form ... <input type="submit" value="Add" action="add"> <input type="submit" value="Delete" action="remove"> in your forms processing use the following switch ($_POST['action'] { case "add": ...do add stuff.... break; case "remove": ...do removal.... break; } See http://www.php.net/switch for more info.

« previous php.general (#179804) next »