Page-Style Selecter (Intermediate/Hard)
Josh-
Royal Oak, MI
Page-Style Selecter
-- written by Josh
To start off, I only had part of the code done. After SL tutorial database opened back up, I looked up to see if they had something similar, so I can get there cookie setup, and I did. So the cookie/html form type part I would have to give credit to them. Thanks Shockingbird..
For this tutorial you will need to create 1 file, and modify the header of your page(s):
Style.php
[php]
<?php
switch ($diffstyle) {
case "style1":
include "style1/header.php";
break;
case "style2":
include "style2/header.php";
break;
default:
print "Error: No style has been selected.";
break;
}
?>
<?php if ($BeenSubmitted) {
setcookie("style", "$newstyle", time()+ "10000000",
"/", ".yourdomain.com",";");
$diffstyle = $newstyle;
} ?>
[/php]
Change your includes to what you need, not very hard.
Style-changing page
[php]
<FORM ACTION="style.php" METHOD=POST><b>Select your favorite Style</b><br>
<SELECT NAME="newstyle"><OPTION VALUE=style1>Style One - Name of style</OPTION>
<OPTION VALUE=style2>Style Two - Name of style</OPTION>
</SELECT>
<INPUT TYPE=HIDDEN NAME=BeenSubmitted VALUE=TRUE>
<INPUT TYPE=SUBMIT NAME="SUBMIT" VALUE="Submit!"><br>
</FORM>
[/php]
Put this at the header of your page(s):
[php]
<? include ("/path/to/your/config/file/config_head.php");
?>
[/php]
Along with..
[php]
<?php if ($BeenSubmitted) {
setcookie("style", "$newstyle", time()+ "10000000",
"/", ".yourdomain.com",";");
$diffstyle = $newstyle;
} ?>
[/php]
And your done!
--Josh
-- written by Josh
To start off, I only had part of the code done. After SL tutorial database opened back up, I looked up to see if they had something similar, so I can get there cookie setup, and I did. So the cookie/html form type part I would have to give credit to them. Thanks Shockingbird..
For this tutorial you will need to create 1 file, and modify the header of your page(s):
- style.php
Style.php
[php]
<?php
switch ($diffstyle) {
case "style1":
include "style1/header.php";
break;
case "style2":
include "style2/header.php";
break;
default:
print "Error: No style has been selected.";
break;
}
?>
<?php if ($BeenSubmitted) {
setcookie("style", "$newstyle", time()+ "10000000",
"/", ".yourdomain.com",";");
$diffstyle = $newstyle;
} ?>
[/php]
Change your includes to what you need, not very hard.
Style-changing page
[php]
<FORM ACTION="style.php" METHOD=POST><b>Select your favorite Style</b><br>
<SELECT NAME="newstyle"><OPTION VALUE=style1>Style One - Name of style</OPTION>
<OPTION VALUE=style2>Style Two - Name of style</OPTION>
</SELECT>
<INPUT TYPE=HIDDEN NAME=BeenSubmitted VALUE=TRUE>
<INPUT TYPE=SUBMIT NAME="SUBMIT" VALUE="Submit!"><br>
</FORM>
[/php]
Put this at the header of your page(s):
[php]
<? include ("/path/to/your/config/file/config_head.php");
?>
[/php]
Along with..
[php]
<?php if ($BeenSubmitted) {
setcookie("style", "$newstyle", time()+ "10000000",
"/", ".yourdomain.com",";");
$diffstyle = $newstyle;
} ?>
[/php]
And your done!
--Josh
0