Jump to content

Getting a value from the url


_Unique_

Recommended Posts

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.

Edited by _Unique_
Link to comment
Share on other sites

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
Share on other sites

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
Share on other sites

 

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.