Help - Search - Members - Calendar
Full Version: [resolved] Skins Help
Codegrrl.com Forums > Script Help > Tutorial Help
Phenix
For some reason when choosing the 2nd skin, once you go to another page it switches back to the 1st. I've tried troubleshooting it yet im not sure the problem, I seem to be doing everything right. Could anyone help? Please and Thank You!

index2.php
CODE
<?php include("/mnt/w0603/d08/s07/b025e6a3/www/vintage/cookiecheck.php");
include($headervar.$skin.$extension);
mysql_connect ('****', '****', '****');
mysql_select_db ('****');

$total_skins = 2;
$default_skin = 2;

if (isset($_REQUEST['newskin'])) {
    $newskin=(int)$_REQUEST['newskin'];
    if (($newskin<1) OR ($newskin>$total_skins)) $newskin = $default_skin;
}
elseif (isset($_REQUEST['skin'])) {
    $newskin=(int)$_REQUEST['skin'];
    if (($newskin<1) OR ($newskin>$total_skins)) $newskin = $default_skin;
}
else $newskin = $default_skin;

$skin = $newskin;

setcookie ('skin', "", time() - 3600);
setcookie('skin',$newskin,time()+(86400*365),'/');
setcookie('skin',$newskin,time()+(86400*365),'/','.walkinginchrist.org/vintage');

$skin = $newskin;


$headervar = "/mnt/w0603/d08/s07/b025e6a3/www/vintage/nav/header";
$footervar = "/mnt/w0603/d08/s07/b025e6a3/www/vintage/nav/footer";
$extension = ".php";

?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>

<head>
  <title>Test your new skin out!</title>

<?php include ($headervar.$skin.$extension); ?>

<h1>Like it?</h1>
<p>Your skin number has been reset to '<?php echo $skin; ?>.' Like it? If so, journey onto the <a href="/">main page</a> of this site and play with it a bit. If it's not quite what you want, you can always <a href="skins.php">go back</a> and select another.</p>

<p>If you run into problems with any of the skins, drop me an email, okay? :)</p>

<? include($footervar.$skin.$extension); ?>


cookiecheck.php
CODE
<?php
$total_skins = 2;
$default_skin = 1;

if (isset($_REQUEST['newskin'])) {
    $newskin=(int)$_REQUEST['newskin'];
    if (($newskin<1) OR ($newskin>$total_skins)) $newskin = $default_skin;
}
elseif (isset($_REQUEST['skin'])) {
    $newskin=(int)$_REQUEST['skin'];
    if (($newskin<1) OR ($newskin>$total_skins)) $newskin = $default_skin;
}
else $newskin=$default_skin;

$skin = $newskin;

setcookie ('skin', "", time() - 3600);
setcookie('skin',$newskin,time()+(86400*365),'/');
setcookie('skin',$newskin,time()+(86400*365),'/','.walkinginchrist.org/vintage');

$skin = $newskin;


$headervar = "/mnt/w0603/d08/s07/b025e6a3/www/vintage/nav/header";
$footervar = "/mnt/w0603/d08/s07/b025e6a3/www/vintage/nav/footer";
$extension = ".php";
?>
Amelie
Try changing these parts:

CODE
if (isset($_REQUEST['newskin'])) {
    $newskin=(int)$_REQUEST['newskin'];
    if (($newskin<1) OR ($newskin>$total_skins)) $newskin = $default_skin;
}
elseif (isset($_REQUEST['skin'])) {
    $newskin=(int)$_REQUEST['skin'];
    if (($newskin<1) OR ($newskin>$total_skins)) $newskin = $default_skin;
}


To this:

CODE
if (isset($_GET['newskin'])) {
    $newskin=(int)$_GET['newskin'];
    if (($newskin<1) OR ($newskin>$total_skins)) $newskin = $default_skin;
}
elseif (isset($_COOKIE['skin'])) {
    $newskin=(int)$_COOKIE['skin'];
    if (($newskin<1) OR ($newskin>$total_skins)) $newskin = $default_skin;
}


Also, you have a different default skin in your cookiecheck.php file and your index2.php file - cookiecheck.php says the default skin is 1, while index2.php says it is 2.
Phenix
That didn't work. sad.gif Thanks though, I didn't realize that they had two different defaults.

[[ edit ]]


Now it works! Thanks for your help! I just had to change the links in my navigation from http://website.com to http://www.website.com. biggrin.gif
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.