cry of war Posted August 24, 2007 Share Posted August 24, 2007 Im trying to get a form to work on a admin page Im making for my game. I know how to make the php register a single form on a page and bring its self back to the same page but i was wondering how do I make it so a person can subit the different froms with out making multiple pages of php and linking them through the action tag. this is the php code i have so far where it goes from he depends on how the coding goes so it really basic for right now. <html> <?php $add="adminadded.php" ?> <title>Admin Edit</title> <body> <h3> Welcome Admin </h3> Manipulate Player Stats <form action="<?php echo $add ?>" method="post"> <input type="submit" value="manipulate" name="Update" /> </form> Add/Delete Weapon <form action="<?php echo $add ?>" method="post"> <input type="submit" value="weapon" name="Update" /> </form> Add/Delete Skill <form action="<?php echo $add ?>" method="post"> <input type="submit" value="skill" name="Update" /> </form> Add/Delete Feat <form action="<?php echo $add ?>" method="post"> <input type="submit" value="feat" name="Update" /> </form> Add/Delete Monster <form action="<?php echo $add ?>" method="post"> <input type="submit" value="monster" name="Update" /> </form> Add/Ban/Delete User <form action="<?php echo $add ?>" method="post"> <input type="submit" value="user" name="Update" /> </form> </body> </html> Quote Link to comment Share on other sites More sharing options...
soycharliente Posted August 24, 2007 Share Posted August 24, 2007 What are you trying to accomplish by having so many different forms with only a submit button in them? Quote Link to comment Share on other sites More sharing options...
cry of war Posted August 24, 2007 Author Share Posted August 24, 2007 I have a few friends that are going to help me with a game and this page is going to be set up so they can insert information directly into a db so that others can use the information on the game. more of a way to let them help me but not mess up my db and tables too badly Quote Link to comment Share on other sites More sharing options...
xyn Posted August 24, 2007 Share Posted August 24, 2007 have one form. several buttons Quote Link to comment Share on other sites More sharing options...
lemmin Posted August 24, 2007 Share Posted August 24, 2007 There is no reason to use multiple forms, that I can think of. You accomplish what you are trying to do with all that code the same, but only one form and changing the names of the submit buttons. Instead of one common name, give them the same name as the value (or whatever name you want, but all different). When you click a submit button that is named, that name is put into the $_POST array (or $_GET) so all you have to do is something like: if (isset($_POST["manipulate"]) \\manipulate something! else if (isset($_POST["weapon"]) \\weapon something? etc. Quote Link to comment Share on other sites More sharing options...
cry of war Posted August 24, 2007 Author Share Posted August 24, 2007 So is the name or the value tag put into the $_Post? Quote Link to comment Share on other sites More sharing options...
lemmin Posted August 24, 2007 Share Posted August 24, 2007 Name, the value tag is what is displayed on the button, only. Quote Link to comment Share on other sites More sharing options...
GingerRobot Posted August 24, 2007 Share Posted August 24, 2007 Perhaps an example? <?php if(isset($_POST['submit1'])){ echo 'You clicked the first submit button!'; }elseif(isset($_POST['submit2'])){ echo 'You clicked the second submit button!'; }else{ echo 'You havn\' pressed a button yet'; } ?> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST" /> <input type="submit" name="submit1" value="Click Me!" /><br /> <input type="submit" name="submit2" value="No, Click Me!" /> </form> Quote Link to comment Share on other sites More sharing options...
cry of war Posted August 24, 2007 Author Share Posted August 24, 2007 oh ok that would explain a lot i had thought it was the other way around thank you Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.