View previous topic :: View next topic |
Author |
Message |
some random person -
Joined: 06 Oct 2003 Posts: 128 Location: I live here! At my house!
|
Posted: Fri Jan 30, 2004 2:26 am Post subject: Need help with script |
|
|
Well... I'm not good at all with php, and was working on a script.
Code: |
<?PHP
include('vars/page_vars.php');
if(!isset($_COOKIE['template_set']))
{if($_COOKIE['template_set'] = '1')
{$INFO['template'] = '0';}
else
if($_COOKIE['template_set'] = '0')
{$INFO['template'] = '0';}}
else
{$INFO['template'] = '0';}
if($INFO['template'] = "0")
{include('templates/00.php');}
else
{
if($INFO['template'] = "1")
{
include('templates/01.php');
}
}
$INFO['page'] = $_GET["page"];
if ($INFO['page'] == "home")
{include('index2.php');}
else
if ($INFO['page'] == "about")
{include('about_us.php'); }
else
if ($INFO['page'] == "members")
{include('members.php');}
else
if ($INFO['page'] == "credits")
{include('credits.php');}
else
if ($INFO['page'] == "admin")
{include('admins.php');}
else
if($INFO['page'] == "")
{include('index2.php');}
else
if($INFO['page'] == "template_change")
{include('vars/change_t.php');}
else
if($INFO['page'] == "template_change_back")
{include('vars/change_t_back.php');}
else
{include('404error.php');}
if($INFO['template'] = "0")
{
include('templates/00_b.php');
}
else
{
if($INFO['template'] = "1")
{
include('templates/01_b.php');
}
}
?>
|
Now, i'm trying to make it when a user goes the the page it will display the defualt template of templates/00.php. If the cookie isn't set, then the variable template will be 0 making it show templates/00.php. But instead, it shows 01.php. I even tried comment the cookie part out and putting $INFO['template'] = 0 and it still shows templates/01.php. So, why is it doing that?
Like I said, i'm new to php and I could be totaly off here... But I tried :wink:
Btw, thats my index.php file. _________________ New image comming soon...
Image hosted by abyss powered website
Image copyright some random person (I made it......)
Abyss > Apache (Meaning abyss is better than apache)
My site powered by abyss->(Undergoing construction)
Last edited by some random person on Sat Jan 31, 2004 3:26 am; edited 1 time in total |
|
Back to top |
|
 |
Moxxnixx -
Joined: 21 Jun 2003 Posts: 1226 Location: Florida
|
Posted: Fri Jan 30, 2004 9:12 pm Post subject: |
|
|
Does your setcookie have a value of whatever template is currently set to? |
|
Back to top |
|
 |
some random person -
Joined: 06 Oct 2003 Posts: 128 Location: I live here! At my house!
|
Posted: Sat Jan 31, 2004 3:20 am Post subject: |
|
|
Well by default i'm trying to make it so if the cookie isn't set, the value of the variable is 0. So to set it, there is a link to click on that brings me to the page that sets the cookie to a value of one.
Also, heres the code for the page that sets the cookie:
Code: |
<?PHP
if($_COOKIE['template_set'] = "1")
echo "You have already chosen this template!";
else
{
setcookie('con_templates', '1', time()+36000);
if($_COOKIE['template_set'] = "1")
echo "Template changed!";
else
echo "Error while changing templates";
}
?>
|
Here, if the value is already one it just stops and says it's already at 1. It it isn't, it goes on and if the value is one after the change it prints the message. But anytime I go to that page it says it's already set to one. _________________ New image comming soon...
Image hosted by abyss powered website
Image copyright some random person (I made it......)
Abyss > Apache (Meaning abyss is better than apache)
My site powered by abyss->(Undergoing construction) |
|
Back to top |
|
 |
some random person -
Joined: 06 Oct 2003 Posts: 128 Location: I live here! At my house!
|
Posted: Sat Jan 31, 2004 6:27 pm Post subject: |
|
|
Ok... I got it. I need to put another == in the if else statments. Now the cookie won't set...
Code: |
<?PHP
echo "Beginning template change... ";
if($_COOKIE['template_set'] == "1")
echo "You have already chosen this template!";
else
{
setcookie('template_set', '1', time()+36000);
echo "Setting cookie...";
if($_COOKIE["con_templates"] == "1")
echo "Template changed! This setting will not take place untill you refreash the page.";
else
echo "<br>Error while changing templates";
}
?>
|
It gets up to the cookie part, but doesn't set it. _________________ New image comming soon...
Image hosted by abyss powered website
Image copyright some random person (I made it......)
Abyss > Apache (Meaning abyss is better than apache)
My site powered by abyss->(Undergoing construction) |
|
Back to top |
|
 |
Moxxnixx -
Joined: 21 Jun 2003 Posts: 1226 Location: Florida
|
|
Back to top |
|
 |
some random person -
Joined: 06 Oct 2003 Posts: 128 Location: I live here! At my house!
|
Posted: Sun Feb 01, 2004 1:17 am Post subject: |
|
|
Ok, i'll take a look. Thanks. _________________ New image comming soon...
Image hosted by abyss powered website
Image copyright some random person (I made it......)
Abyss > Apache (Meaning abyss is better than apache)
My site powered by abyss->(Undergoing construction) |
|
Back to top |
|
 |
|