Forum Moderators: coopster

Message Too Old, No Replies

php $_GET and include trouble

         

blinkage

4:51 am on Sep 7, 2005 (gmt 0)

10+ Year Member



I am currently using this code on my index.php for includes so that my url's are index.php?nav=counters etc etc.

<?php
if($_GET['nav']=='counters'){
include("counters.html");}
elseif($_GET['nav']=='mail'){
include("mail.html");}
elseif($_GET['nav']=='images'){
include("upload.php");}
elseif($_GET['nav']=='upload'){
include("upload.php?mode=upload");}
elseif($_GET['nav']=='thanks'){
include("thanks.html");}
elseif($_GET['nav']=='code'){
include("code.php");}
elseif($_GET['nav']=='support'){
include("support.html");}
elseif($_GET['nav']=='page1'){
include("page1.html");}
elseif($_GET['nav']=='page2'){
include("page2.html");}
elseif($_GET['nav']=='page3'){
include("page3.html");}
elseif($_GET['nav']=='page4'){
include("page4.html");}
elseif($_GET['nav']=='page5'){
include("page5.html");}
else{
include("updates/news.php");
}
?>

For nav=images it called another php script allowing users to upload images. After submitting, this script requires a?mode=upload to know to put out the success message and what not. The action for the submit button is set to index.php?nav=upload which then called upload.php?mode=upload. You'll see where nav=upload.php?mode=upload. This does not work. Instead of calling upload.php and giving it?mode=upload, it just looks for file name upload.php?mode=upload and does not find it. How can I get around this?

blinkage

4:55 am on Sep 7, 2005 (gmt 0)

10+ Year Member



I don't know if articulated that very well. The jist of what I am asking is how do I assign?mode=upload to the included file upload.php.

chrisjoha

6:13 am on Sep 7, 2005 (gmt 0)

10+ Year Member



Well, to send more than one parameter, do as follows: nav.php?arg1=value&arg2=value2

You could solve your problem like this: index.php?nav=upload&mode=upload

Then when you include the script $_GET['mode'] will give you the mode, since an included file is within the scope of the including script (ie all variables available at the point of include is available inside the included script. Additionally, $_GET is always available)

blinkage

6:35 am on Sep 7, 2005 (gmt 0)

10+ Year Member



Thank you sir! That solved my problem. It was as simple as adding &mode=upload to the end.