[SOLVED]Redirecting and so on...

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Post by Ambush Commander »

Err... yeah, it does. Ever hear about a handy function called exit?

Code: Select all

if (isset($_COOKIE['ver']) AND empty($_GET['ver'])) {
  $ver = $_COOKIE['ver'];
} elseif (isset($_GET['ver'])) {
  $ver = $_GET['ver'];
  setcookie('ver',$ver);
} else {
  //Show Splash Page
  exit;
}
 
//Show Main page with $ver as the language indicator
theda
Forum Contributor
Posts: 332
Joined: Sat Feb 19, 2005 8:35 am
Location: USA

Post by theda »

y'know, I've seen it... But since I just came from HTML... Never used it ^_^. But your help will slowly cause me to learn php! And soon I shall take over the world... One byte at a time. After my coffee that is. Heh. Thanks for the help.

Edit: Problem again! Now it just keeps running the "Splash" page and never actually runs the content.
theda
Forum Contributor
Posts: 332
Joined: Sat Feb 19, 2005 8:35 am
Location: USA

Post by theda »

Yeah. For some reason, it will never load the other content...
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Post by Ambush Commander »

The EXIT must be inside the ELSE otherwise it'll be parsed every time. If you're being shown the Splash every time, then there's something wrong with the logic. Post the code.
theda
Forum Contributor
Posts: 332
Joined: Sat Feb 19, 2005 8:35 am
Location: USA

Post by theda »

Sorry for the late response...

Code: Select all

<?
if (isset($_HTTP_COOKIE_VARS['ver']) AND empty($_GET['ver'])) {
  $ver = $_HTTP_COOKIE_VARS['ver'];
} elseif (isset($_GET['ver'])) {
  $ver = $_GET['ver'];
  setcookie('ver',$ver);
} else {
print "
<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">
<html>
	<head>
		<title>theda</title>
		<meta http-equiv=\"Content-Type\" content=\"text/html;charset=utf-8\">
	</head>
	<body bgcolor=\"#000000\"><table><center><br>
			<TABLE BORDER=\"0\" CELLPADDING=\"0\" CELLSPACING=\"0\" WIDTH=\"640\" HEIGHT=\"480\" align=\"center\">
				<TR>
					<TD ROWSPAN=\"1\" COLSPAN=\"2\" WIDTH=\"640\" HEIGHT=\"432\">
						<IMG SRC=\"splash.jpg\" WIDTH=\"640\" HEIGHT=\"432\" BORDER=\"0\">
					</TD>
				</TR>
				<TR>
				<TD ROWSPAN=\"1\" COLSPAN=\"1\" WIDTH=\"297\" HEIGHT=\"48\">
						<A HREF=\"http://dumbass.ionichost.com/?ver=en\"><IMG SRC=\"en_splash.jpg\" WIDTH=\"297\" HEIGHT=\"48\" BORDER=\"0\" ALT=\"English\"></A>
					</TD>
					<TD ROWSPAN=\"1\" COLSPAN=\"1\" WIDTH=\"343\" HEIGHT=\"48\">
						<A HREF=\"http://dumbass.ionichost.com/?ver=de\"><IMG SRC=\"de_splash.jpg\" WIDTH=\"343\" HEIGHT=\"48\" BORDER=\"0\" ALT=\"Deutsch\"></A>
					</TD>
				</TR>
			</TABLE>
		</table>
	</body>
</html>
<noscript>";
	exit;
}

//Version Flag Variable
$change = $ver."_flag.jpg";

//Opposite Version Variable
if($ver == "en")  {
	$ver2 = "de"; 
} else {
	$ver2 = "en"; 
}

//Style Inclusion
include($ver.".style.php");

//Page Information
if (isset($id)) {
	$id = $id;
} else {
	$id = $ver.".news";
}
switch($ver)
{
  case 'de':
    switch($id)
    {
      case 'de.link':
      case 'de.cont':
        $sec_i = 'Wenn Sie diese Netplatz magen, dann hier ist, alles das Sie möchten.';
        break;
      case 'de.gallery':
        $sec_i = 'Schauen Sie durch meinen Galerien und bemängeln Sie mir, dass Sie möchten.';
        break;
      case 'de.news':
      default:
        $sec_i = 'Lesen Sie über meinem Leben und machen Sie eiligen Urteile.';
        break;
    }
    break;

  case 'en':
  default:
    switch($id)
    {
      case 'en.link':
      case 'en.cont':
        $sec_i = 'If you actually like what is on this site, all the information you need is here.';
        break;
      case 'en.gallery':
        $sec_i = 'Look through snapshots of my life and criticize them as you feel.';
        break;
      case 'en.news':
      default:
        $sec_i = 'Read about my eventful life here and make your judgements swiftly.';
        break;
    }
    break;
}
//Website Content
include($ver.".content.php");

?>
<noscript>
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Post by Ambush Commander »

You must use $HTTP_GET_VARS
theda
Forum Contributor
Posts: 332
Joined: Sat Feb 19, 2005 8:35 am
Location: USA

Post by theda »

Now the problem is, with doing that... it doesn't look for the cookie.

Edit: I replaced the wrong variables... I got it fixed now. For now, I'm going to say everything is good. I'll harass you more if there is something wrong ^_^.

Next off the bat: Cleaning up my code and parsing it all...
Post Reply