n00b_user Posted December 6, 2008 Share Posted December 6, 2008 Umm.. I think I accidently added this to the subsection >.< :-\ oopsies, soz So, pardon my noobish question Once upon a time I was able to do this, and I've forgotten everything (you know, if you don't use it, ya lose it...) Unfourtunatly, I don't even know how to describe it, and I've tried googling it, but I don't know what: ".extension?action=result" is called, specifically because I don't know if "action" is a function, a variable, or a special syntax Here's my quick explanation: I want to be able to put every "action" onto a page called actions.php I then want to click on the Submit button found on index.php The form on index.php is set to: action="actions.php?doThis" (Where "doThis" is: addUser, updateUser, etc) Example: Basically, I want 1 page (actions.php) to do 4 different things. They are: [*] validate user [*] add user [*] update user [*] delete user I know how to DO all of these things on 4 separate pages, but I don't want 4 separate pages. I want 1 page. Now, I've created my actions.php page And have tried making "doThis" a function and a variable, and I'm not getting any output I'm sure you've seen this many times before in a link. Especially when inputting a username and password: http://www.mysite.com/login.php?userID=785765 So my questions are: [*] What is this called so I know what I'm doing? [*] How do I do this? As in: what format should "doSomething" be in, so that it registers and outputs what I want it to without having to make 50 different pages? Thanks in advance Link to comment https://forums.phpfreaks.com/topic/135836-phpdothis/ Share on other sites More sharing options...
n00b_user Posted December 6, 2008 Author Share Posted December 6, 2008 I guess, since it's in the wrong section - I won't get any replies :'( Am I allowed to recreate the post in the correct section? Or get it moved? Or just suffice with no answer ??? Link to comment https://forums.phpfreaks.com/topic/135836-phpdothis/#findComment-708062 Share on other sites More sharing options...
premiso Posted December 6, 2008 Share Posted December 6, 2008 action="actions.php?doThis" should be action="actions.php?action=doThis" Then on your actions.php page: <?php $action = isset($_GET['action'])?$_GET['action']:'none'; if ($action == "none") { die("No action provided"); } switch ($action) { case 'add': addUser($_POST['username']); break; case 'delete': deleteUser($_POST['delete']); break; } ?> Should get you the desired result. Link to comment https://forums.phpfreaks.com/topic/135836-phpdothis/#findComment-708087 Share on other sites More sharing options...
Mchl Posted December 6, 2008 Share Posted December 6, 2008 Read about $_GET variable If you have index.php?action=doThis then in index.php $action = $_GET['action']; //$action is now "doThis" Link to comment https://forums.phpfreaks.com/topic/135836-phpdothis/#findComment-708089 Share on other sites More sharing options...
n00b_user Posted December 11, 2008 Author Share Posted December 11, 2008 awesome tyvm for the help~! Link to comment https://forums.phpfreaks.com/topic/135836-phpdothis/#findComment-713082 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.