_Unique_ Posted May 5, 2015 Share Posted May 5, 2015 Hello, I know this question has been previously asked either on this forums or elsewhere, but all of the questions I could find were asking for the path, whereas I am asking for the value. Okay, now for the question and explanation. How can I get the value from a url, for example; If the url is http://mywebsite.com/install/install.php?step=2 How could I get the value 2 so I can only show the content for that step and not for any other step. Thanks in advance, Unique EDIT: Okay, I just solved my own question with $_GET['step']. But I have another question, how could I automatically assign a step to the user once they are on the page, so the will automatically start on Step 0 (the introduction) then move onto step 1 once the have pressed a link or a button, then move onto step 2, etc, etc. Link to comment https://forums.phpfreaks.com/topic/296080-getting-a-value-from-the-url/ Share on other sites More sharing options...
ginerjm Posted May 5, 2015 Share Posted May 5, 2015 You don't provide nearly enough info to help us to help you. How did they get to the page they are on? If they are on a specific page, how do you know they don't want to stay on that page and not go to your idea of the page they should be on? If they got to this page, why should they be re-directed? How did they get to this page anyway? If you had a specific entry page/point for your 'steps', then the way to progress thru the series would be to have 'Next' and 'Prev' buttons that have the proper urls in them. Theses would be setup by your script that generates each page. (if generating page 4 then you would create the Next button with a "?step=5" and the Prev button with a "?step=3" in the src of any link tag or the action of any form tag.) Link to comment https://forums.phpfreaks.com/topic/296080-getting-a-value-from-the-url/#findComment-1510842 Share on other sites More sharing options...
_Unique_ Posted May 5, 2015 Author Share Posted May 5, 2015 The page I am creating is an install script, it automatically connects the database, creates the admins, uploads the database, etc. There are going to be steps, that the user has to follow, starting from step 0, which I am hoping to force the user to start on that step. As it is an install script, I have made it so any page that the user attempts to load, they will be automatically redirected to the install page, until the website is setup. I have already created this script, and it is fully functional. I just need help with creating each step, so when the user first starts the install, they will start on step 0, then when they have finished step 0, they can press the next button, which will take them to step 1, etc. I just need help forcing the user to start on step 0, and then automatically changing the Step value in the url. I already know how to pull the value from the url. Sorry about not giving enough information, hopefully this makes it more clearer. Link to comment https://forums.phpfreaks.com/topic/296080-getting-a-value-from-the-url/#findComment-1510843 Share on other sites More sharing options...
Psycho Posted May 5, 2015 Share Posted May 5, 2015 Personally, I would use session values instead of values on the query string, but since that is what you are using: $step = isset($_GET['step'])) ? intval($_GET['step']) : 0; Link to comment https://forums.phpfreaks.com/topic/296080-getting-a-value-from-the-url/#findComment-1510844 Share on other sites More sharing options...
_Unique_ Posted May 5, 2015 Author Share Posted May 5, 2015 Personally, I would use session values instead of values on the query string, but since that is what you are using: $step = isset($_GET['step'])) ? intval($_GET['step']) : 0; Okay, thanks, how would I go about doing it with session values? Link to comment https://forums.phpfreaks.com/topic/296080-getting-a-value-from-the-url/#findComment-1510845 Share on other sites More sharing options...
Psycho Posted May 5, 2015 Share Posted May 5, 2015 Okay, thanks, how would I go about doing it with session values? $step = isset($_SESSION['step'])) ? intval($_SESSION['step']) : 0; But, I'm not going to give you a tutorial of how to set and manage session variables. Go do some research first. Link to comment https://forums.phpfreaks.com/topic/296080-getting-a-value-from-the-url/#findComment-1510847 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.