Hyperjase Posted November 14, 2011 Share Posted November 14, 2011 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 Quote Link to comment https://forums.phpfreaks.com/topic/251138-image-based-_post-along-with-multiple-pages-in-one-php-file/ Share on other sites More sharing options...
requinix Posted November 15, 2011 Share Posted November 15, 2011 if(isset($_GET['step']) == 2) You're trying to combine two different things into that one condition. They need to be separate: if the step is set and the step is 2. Quote Link to comment https://forums.phpfreaks.com/topic/251138-image-based-_post-along-with-multiple-pages-in-one-php-file/#findComment-1288182 Share on other sites More sharing options...
Hyperjase Posted November 15, 2011 Author Share Posted November 15, 2011 Ah, yes I follow, so it should be: if(isset($_GET['step']) & ($_GET['step'] = 2)) I think? I'm not sure about the end part, it may be simpler than that. Thanks, Jason Quote Link to comment https://forums.phpfreaks.com/topic/251138-image-based-_post-along-with-multiple-pages-in-one-php-file/#findComment-1288307 Share on other sites More sharing options...
PFMaBiSmAd Posted November 15, 2011 Share Posted November 15, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/251138-image-based-_post-along-with-multiple-pages-in-one-php-file/#findComment-1288309 Share on other sites More sharing options...
Hyperjase Posted November 15, 2011 Author Share Posted November 15, 2011 Thanks, think I'm following, with the second piece of code I would be able to make step 2 as if $step = 2 { do whatever} Would work right? Thanks, Jason Quote Link to comment https://forums.phpfreaks.com/topic/251138-image-based-_post-along-with-multiple-pages-in-one-php-file/#findComment-1288429 Share on other sites More sharing options...
Hyperjase Posted November 16, 2011 Author Share Posted November 16, 2011 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 Quote Link to comment https://forums.phpfreaks.com/topic/251138-image-based-_post-along-with-multiple-pages-in-one-php-file/#findComment-1288747 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.