Welcome to Dream.In.Code
Getting PHP Help is Easy!

Join 136,582 PHP Programmers for FREE! Get instant access to thousands of PHP experts, tutorials, code snippets, and more! There are 1,924 people online right now. Registration is fast and FREE... Join Now!




Muti submit elemts in single form.

 
Reply to this topicStart new topic

Muti submit elemts in single form.

engale
6 Oct, 2008 - 08:55 AM
Post #1

D.I.C Addict
Group Icon

Joined: 30 Sep, 2008
Posts: 549



Thanked: 2 times
Dream Kudos: 50
My Contributions
useing a form I've tested and found out that it is easy to add a name tag to the submit button and the value, and treat this element like a regular input element, I'm guessing that this is ok but I want more of a conformation on the idea. I've never had reason to check this out before but I'm working on a script where I can either use multipal submit statments in the single form or create the same form over and over again.

Thoughts or advice on this situation is well wanted. Thanks in advance.

A code to describe what I mean:

CODE

<?
if ( $_POST['mode'] == "edit" ) {
  echo "you decided to edit page " . $_POST['page'] . ".";
}
elseif ( $_POST['mode'] == "delete" ) {
  echo "you decided to delete page " . $_POST['page'] . ".";
}
else {
?>
<form action="<? echo $_SERVER['PHP_SELF']; ?>" method="POST">
<select name="page">
<option>Page One</option>
<option>Page Two</option>
<option>Page Three</option>
</select>
<input type="submit" name="mode" value="edit">
<input type="submit" name="mode" value="delete">
</form>
<?
}
?>

User is offlineProfile CardPM
+Quote Post

Hary
RE: Muti Submit Elemts In Single Form.
6 Oct, 2008 - 12:53 PM
Post #2

D.I.C Head
**

Joined: 23 Sep, 2008
Posts: 205



Thanked: 15 times
My Contributions
Yes, that would work. But it is wiser to take different names for the submit tags, as only one element can have a certain name on a page, you could check the name having a certain value to check the submit element.
User is offlineProfile CardPM
+Quote Post

engale
RE: Muti Submit Elemts In Single Form.
6 Oct, 2008 - 07:17 PM
Post #3

D.I.C Addict
Group Icon

Joined: 30 Sep, 2008
Posts: 549



Thanked: 2 times
Dream Kudos: 50
My Contributions
Thanks, that makes good sence.
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/3/08 12:33AM

Live PHP Help!

PHP Tutorials

Reference Sheets

PHP Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month