Jump to content

[SOLVED] just a little problem


jeppers

Recommended Posts

i am trying to write some simple code but i am not as sure if its the code or my browser...

 

what i am trying to do is write some code which will allow the users to change there setting i.e font color, bg_color...

 

i have written 2 x script but when i run them i am not sure if the browser stopping the cookies or my scripts..

 

could you have a look and see what you think..

 

 

<b>The form which is used to customizes </b>

<?php //customize.php

//address error handling
ini_set ('display_errors', 1);
error_reporting (E_ALL & ~E_NOTICE);

$cookies = FALSE; // cookies have not been sent 

//handle form, if it has not been submitted 
if (isset ($_POST['submit'])) {

//send the cookies 
setcookie ('bg_color', $_POST['bg_color']);
setcookie ('font_color', $_POST['font_color']);

$cookies = TRUE; // cookies have been set 

}// end of submit if
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Custermize your settings</title>
</head>

<body>
<?php
//if cookies have been sent print htis message 
if ($cookies) {
print '<p>Your settings have been entered! Click <a href="view_settings.php">Here</a> to back to the main page.</p>';
}
?>

<p><strong>use this form to set your preferences:</strong></p>
<form action="customize.php" method="post">
<select name="bg_color">
<option value="">BackGround Color</option>
<option value="#ffffff">White</option>
<option value="#00cc00">Green</option>
<option value="#0000ff">Blue</option>
<option value="#cc0000">Red</option>
<option value="#000000">Black</option>
</select>
<select name="font_color">
<option value="">Font Colour</option>
<option value="#ffffff">White</option>
<option value="#00cc00">Green</option>
<option value="#0000ff">Blue</option>
<option value="#cc0000">Red</option>
<option value="#000000">Black</option>
</select>
<input type="submit" name="submit" value="Set My Preferences" />
</form>


</body>
</html>

 

The code which catches the data from the cookies

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>View Your Setting</title>
<style type="text/css">
body {
	background-color:#FFFFFF;
	color: #000000;
<?php // view_setting.php

//address error handling
ini_set ('display_errors', 1);
error_reporting (E_ALL & ~E_NOTICE);

//check for a bg_color value
if (isset ($_COOKIE['bg_color'])) {
print "\t\tbackground-color:{$_COOKIE['bg_color']};\n";
}else{
print"\t\tbackground-color:#ffffff;\n";
}

// Check for a font-color value
if (isset($_COOKIE['font_color'])) {
print "\t\tcolor: {$_COOKIE['font_color']};\n";	
}else{
print"\t\tcolor: #000000; \n";
}
?>
}
</style>
</head>

<body>
<p><a href="customize.php">Customize you settings</a></p>
<p><a href="Reset.php">Reset Your settings</a></p>
<p>
<p>yadda yadda yadda yadda yadda yadda yadda yadda yadda yadda</p>
<p>yadda yadda yadda yadda yadda yadda yadda yadda yadda yadda</p>
<p>yadda yadda yadda yadda yadda yadda yadda yadda yadda yadda</p>

</body>
</html>

 

any help will be great full...

 

Link to comment
https://forums.phpfreaks.com/topic/66150-solved-just-a-little-problem/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.