Php skinning w/ cookies question.

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
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

whatever I tried passing to set.php, it always attempted to delete the cookie.
theda
Forum Contributor
Posts: 332
Joined: Sat Feb 19, 2005 8:35 am
Location: USA

Post by theda »

So what should I do?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

figure out whatever is going on in the script that keeps telling it to delete the cookie.. probably a simple logic error.
theda
Forum Contributor
Posts: 332
Joined: Sat Feb 19, 2005 8:35 am
Location: USA

Post by theda »

How am I supposed to know what the hell is going on? If I knew all of php, I wouldnt be asking you for help.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

want to post the entire script, or set of scripts maybe?
theda
Forum Contributor
Posts: 332
Joined: Sat Feb 19, 2005 8:35 am
Location: USA

Post by theda »

My index.php file is okay as long as the ver.php has $ver assigned to either en or de. If it isn't, then it gives errors.

set.php:

<?
setcookie("language", $ver, time()+604800);
?>

ver.php

<?
$ver = $HTTP_COOKIE_VARS["language"];
?>
theda
Forum Contributor
Posts: 332
Joined: Sat Feb 19, 2005 8:35 am
Location: USA

Post by theda »

Now as I said in my previous post, if I were to set ver.php to
<? $ver = "en" ?> then my index.php would show my index page. if I set it to $ver = "de" it would show my german page.

On the ver page, the job it has is to open the cookie up and find what it needs to set $ver to so that index.php knows what to load.

On the set page, it has to be able to set the cookie to either en or de, depending on what (set.php?blah=blah2) blah2 equals.

Edit: with the set.php page, I want to be able to put a link to be able to switch between the "en" and "de" side.
Last edited by theda on Sat Feb 19, 2005 2:47 pm, edited 1 time in total.
theda
Forum Contributor
Posts: 332
Joined: Sat Feb 19, 2005 8:35 am
Location: USA

Post by theda »

I could even put the ver.php code into index.php itself and get the same outcome.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

http://dumbass.ionichost.com/set.php?ver=super

Code: Select all

HTTP/1.1 200 OK
Date: Sat, 19 Feb 2005 20:45:56 GMT
Server: Apache/1.3.26 (Unix) PHP/4.0.6
X-Powered-By: PHP/4.0.6
X-Accelerated-By: PHPA/1.3.3r2
Set-Cookie: language=super; expires=Sat, 26-Feb-05 20:45:56 GMT
Connection: close
Transfer-Encoding: chunked
Content-Type: text/html

<noscript><script language="JavaScript">win155 = window.open('','cons723'); win155.blur();self.focus();var url = "http://" + self.location.host;var file = "/locmntl/hotfreebies.html";if (win155.document.URL.indexOf(url) == -1)    &#123;                                                                                                          win155.location.href = url + file;       &#125;</script>
at least it sets now, using the correct variable name.

what does index.php's code look like?
theda
Forum Contributor
Posts: 332
Joined: Sat Feb 19, 2005 8:35 am
Location: USA

Post by theda »

Code: Select all

<?php

include("ver.php");

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

// Page identification
if (isset($id)) &#123;
	$id = $id;
&#125; else &#123;
	$id = $ver."/news";
&#125;

// Page Information Identification
if ($ver =="en" || $id == "news") &#123;
	// readable
	$sec_i = "Read about my eventful life here and make your judgements swiftly.";
&#125; elseif ($ver =="en" || $id == "gallery") &#123;
	// viewable
	$sec_i = "Look through snapshots of my life and criticize them as you feel.";
&#125; elseif ($ver =="en" || $id == "link" || $id == "cont") &#123;
	// valuable
	$sec_i = "If you actually like what is on this site, all the information you need is here.";

&#125; elseif ($ver =="de" || $id == "link" || $id == "cont") &#123;
	// valuable
	$sec_i = "Wenn Sie diese Netplatz magen, dann hier ist, alles das Sie möchten.";
&#125; elseif ($ver =="de" || $id == "news") &#123;
	// readable
	$sec_i = "Lesen Sie über meinem Leben und machen Sie eiligen Urteile.";
&#125; elseif ($ver =="de" || $id == "gallery") &#123;
	// viewable
	$sec_i = "Schauen Sie durch meinen Galerien und bemängeln Sie mir, dass Sie möchten.";
&#125;






// Begin output of page...
include($ver."/content.php");

?>
<noscript>
Edit: Not related to index.php, but if you notice that things go $ver."/page.php"

It stands for (if $ver = en), then it inputs "en/page.php"

Currently, all my files are in three directories. "en/" "de/" and "/" the main files like index.php, ver.php, and set.php are all in the "/" and the website content is in both "en/" and "de/"


feyd | :roll:
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

visiting http://dumbass.ionichost.com/set.php?ver=en
then http://dumbass.ionichost.com/ should display data, however your logic for checking $id is off, as your default will be "en/news" not "news"
theda
Forum Contributor
Posts: 332
Joined: Sat Feb 19, 2005 8:35 am
Location: USA

Post by theda »

Huh?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

$sec_i will not be set if $id doesn't match 'news', 'gallery', 'link', or 'cont'. Furthermore, if $id is not passed in the request, your "default" '$id = $ver."/news"' will make it not match any of the $sec_i setting filters as well.
theda
Forum Contributor
Posts: 332
Joined: Sat Feb 19, 2005 8:35 am
Location: USA

Post by theda »

So what do you suggest?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

I'd suggest using a nested set of switches

Code: Select all

switch($ver)
&#123;
  case 'de':
    switch($id)
    &#123;
      case 'link':
      case 'cont':
        $sec_i = 'Wenn Sie diese Netplatz magen, dann hier ist, alles das Sie möchten.';
        break;

      case 'news':
      default:
        $sec_i = 'Lesen Sie über meinem Leben und machen Sie eiligen Urteile.';
        break;
    &#125;
    break;

  case 'en':
  default:
    switch($id)
    &#123;
      // etc
    &#125;
    break;
&#125;
Post Reply