PDA

View Full Version : include problems


Snetty
07-21-2005, 01:19 PM
I'm working on my custom checkout page for my new site at the moment, and it seems to be forgetting all of the non-session variables.

$page = "login.php";
include ('./header.php');

if (isset ($_POST['submit1'])) {

include ('./stage1validate.php');

} else if (isset($_POST['submit2'])) {

include ('./stage2validate.php');

} else if (isset($_POST['submit3'])) {

include ('./stage3validate.php');

} else if (isset($_POST['submit4'])) {

include ('./stage4validate.php');

} else if (isset($_POST['submit5'])) {

include ('./stage5.php');

} else {

include ('./stage1view.php');

}

include ('./footer.php');

That's the main checkout.php file. I'm guessing that include's don't pass variables to each other or something... why not? Is there a way around it other than using sessions, which i really don't want to do as I want the variables to die if a customer quits the page before completing checkout.

//edit - scrub that, just made everything into one huge file and i've still got the problem, so i guess it's not include related.

devinemke
07-21-2005, 03:20 PM
included files inheirit the variable scope of the parent script. what excatly is the problem?

ClubCosmic
07-22-2005, 10:45 PM
I think you might want to use a switch (http://us2.php.net/switch) statement here.

switch($submit){
case "submit1":
include ('./stage1validate.php');
break;

case "submit2":
include ('./stage2validate.php');
break;
deafult;
include ('./stage1view.php');
}


in your form give all your submit buttons the same name but different values:
<input type="radio" name="submit" value="submit1">
c.c.