Jump to content

Image based $_POST along with multiple pages in one php file


Hyperjase

Recommended Posts

Hi all,

 

I've done a LOT of googling on this and found things that match what I need but nothing actual achieves what I need.

 

I've used one php file before for doing multiple jobs (ie registration?step=2 / 3 etc), but I've boo-booed somewhere and it only works up until step 2, step 3 doesn't work.  Here's what I have currently, it also leads me on to the next question.

 

<?php if(isset($_GET['step']) == 2) { ?>
   Please select the problem you are encountering.
   <a href="registration.php?step=3&console=<?php $_GET['console'] ?>&issue=1rrod"><img src="store/image/data/1rrod.gif" width="92" height="92" /></a>
   <?php } if (isset($_GET['step']) == 3) { ?>
   END 
   <?php } else {?>
   Please select which type of Xbox 360 you have<br />
    <a href="registration.php?step=2&console=xbox"><img src="images/xbox360.gif"></a>
    <a href="registration.php?step=2&console=xboxslim"><img src="images/xbox360e.gif"></a>    
    <?php } ?>

 

So, first step (which is bottom), lets you select which type of console it is - only two possible choices.  That then passes that data to step 2, which is what issue the console is having. 

 

Now I've tried this with $_POST, as I would prefer to work that way.  I've experimented with $_SESSION to try and pass everything I need, using code found elsewhere.  But I just can't get it to pass from page to page and finally be able to use it to email in the final step.

 

Final issue - I want to use images instead of buttons to be able to pass the variables.  I've found that using hidden type input does work but I think this issue is related to the above one.

 

Thanks!

 

Jason

Link to comment
Share on other sites

isset would be used to test if something is set at all, so that you could decide to use an actual value or use a default value or a default choice.

 

Near the start of your code, you would use one of the following -

 

$_GET['step'] = isset($_GET['step']) ? (int)$_GET['step'] : ''; // replace the '' with whatever default value you want when the step is not provided in the URL

 

or

 

$step = isset($_GET['step']) ? (int)$_GET['step'] : ''; // replace the '' with whatever default value you want when the step is not provided in the URL 

 

Then you would just use $_GET['step'] (1st code) or $step (2nd code) in your logic. You know the value is set to either the integer value of the actual $_GET['step'] value or it is the default value.

 

In general, you would use a switch/case statement when you are going to test for one of several values and execute specific code depending on the value.

 

 

Link to comment
Share on other sites

I eventually used the case system which works perfectly, didn't know about that at all!

 

Now it just leaves with me with one problem, I use post on my forms but when I go to step 2, I use $_POST['console'] to attempt to pull the console form submitted on step 1, but when I try echoing it out it shows nothing. Does it matter that the name on the two inputs inside the form are named differently? I'm extremely confused and aren't sure which way I need to do this!

 

Thanks,

 

Jason

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.