problem with case select code

forcer

OSNN Senior Addict
Joined
18 Oct 2002
Messages
413
PHP:
<?php  
if (!$page) { 
	include 'home.php'; 
} elseif (file_exists($page.".php")) { 
	switch ($page) {  
		case 'home':  
		include 'home.php'; break;
		case 'about':
		include 'about.php'; break;
		case 'profiles':
		include 'profiles.php'; break;
		case 'audio':
		include 'audio.php'; break;
		case 'photos':
		include 'photos.php'; break;
		case 'videos':
		include 'videos.php'; break;
		case 'choons':
		include 'choons.php'; break;
		case 'guestbook':
		include 'guestbook.php'; break;
		case 'links':
		include 'links.php'; break;
		case 'xtra':
		include 'xtra.php'; break;
		case 'contact':
		include 'contact.php'; break;
	default:  
	include '404.php'; 
	} 
	} else { 
	include '404.php'; 
	}
	
	switch ($u) {
		case 'reflex':  
		include 'profiles/reflex.php';  break;
		case 'scottyg': 
                                include 'profiles/scottyg.php'; break;
	}
?>

this is the code i use for my case select... only problem is if i go to the page...
index.php?page=profiles&u=scottyg

it will display profiles page and the scottyg page... but i just want it to display the scotty g page...

how can i fix this?
 
Take out the profiles& line in the code?
I dont know enough to about php to give you a direct answer :/
 
Insert the switch($u) into switch($page) like this:
Code:
<?php
 switch ($page) {  
        case 'bla1':  
        include 'home.php'; break;
        switch($u){
               case 'something':
               DoSomething();
               break;
        }
        default:
         print "booboo";
}

But that would be difficult as you have a lot of cases. But, I think I can remove those cases, just give me a minute, then I shall try something.
 
This might work:
PHP:
<?php  
if (!$page) { 
 include 'home.php'; 

//Does the file exist?
} elseif (file_exists($page.".php")) { 
  //include file with the name of whatever ?page=bert is
  include '$page.php';
 
  //Does the file ($u) exist?
  if (file_exists("profiles/".$u.".php"){
    //include file with the name of whatever &u=ernie is
    include 'profiles/$page.php';
  }else{
    print "I am sorry, but that user does not exist";
  }

}else{ 
 include '404.php'; 

}
    
?>
 
To your first case statement, add another one that called empty, and then instead of your URL being:

index.php?page=profiles&u=scottyg, make it
index.php?page=empty&u=scottyg

:)
 
Originally posted by X-Istence
To your first case statement, add another one that called empty, and then instead of your URL being:

index.php?page=profiles&u=scottyg, make it
index.php?page=empty&u=scottyg

:)

What's the point of that?
 

Members online

No members online now.

Latest profile posts

Also Hi EP and people. I found this place again while looking through a oooollllllldddd backup. I have filled over 10TB and was looking at my collection of antiques. Any bids on the 500Mhz Win 95 fix?
Any of the SP crew still out there?
Xie wrote on Electronic Punk's profile.
Impressed you have kept this alive this long EP! So many sites have come and gone. :(

Just did some crude math and I apparently joined almost 18yrs ago, how is that possible???
hello peeps... is been some time since i last came here.
Electronic Punk wrote on Sazar's profile.
Rest in peace my friend, been trying to find you and finally did in the worst way imaginable.

Forum statistics

Threads
62,015
Messages
673,494
Members
5,621
Latest member
naeemsafi
Back