Jump to content

helpmehelpmehelpme

Members
  • Posts

    30
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

helpmehelpmehelpme's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. okay, it looks like they all work except for the background color and the link color.
  2. i have this example, but im not sure how to do it for the background color and the others, if (isset($_COOKIE['font_color'])) { print "\t\tcolor: #" . htmlentities($_COOKIE['font_color']) . ";\n"; } else { print "\t\tcolor: #000;"; }
  3. it still doesn't work, but could you do an if statement. like if the user selects whatever color from the drop down list, change the styles color or something like that
  4. no errors this time, but it's still not changing the styles on the page. The background is white, it should change when the user selects a color and goes to file3
  5. like this? <style type="text/css"> <!-- These are the styles the session should configure --> a:link {color:#<? $_COOKIE['link_color']; ?>} //Use the variable in the style a:hover {color:#<? $_COOKIE['link_hover_color']; ?>} body {background-color:#<? $_COOKIE['background_color']; ?>} h1 {color:#<? $_COOKIE['header_color']; ?> text-align:center;} </style> it still doesnt change the styles on the page....im confused
  6. sorry, file 2 returned that but when you click click here to see it in action which goes to file3, it says Notice: Undefined index: background_color in C:\xampp\htdocs\xampp\PHP\file3.php on line 10 Notice: Undefined index: link_color in C:\xampp\htdocs\xampp\PHP\file3.php on line 11 Notice: Undefined index: link_hover_color in C:\xampp\htdocs\xampp\PHP\file3.php on line 12 Notice: Undefined index: header_color in C:\xampp\htdocs\xampp\PHP\file3.php on line 13 Welcome to YOUR pretty website Click here to go back and start over! and the original styles are displayed
  7. I tried that instead of it applying the changes to the styles, it prints returns \body: #c00\a:link: #00f Your settings have been updated. Click here to continue. on the page. I don't know, there must be an error somewhere heres the updated code file1.php <?php //Handle the form if it has been submitted: if (isset($_POST['background_color'], $_POST['link_color'], $_POST['link_hover_color'], $_POST['header_color'])){ //send the cookies: setcookie('background_color', $_POST['background_color'], time()+10000000); setcookie('link_color', $_POST['link_color'], time()+10000000); setcookie('link_hover_color', $_POST['link_hover_color'], time()+10000000); setcookie('header_color', $_POST['header_color'], time()+10000000); //Message to be printed later: $msg = '<p>Your settings have been entered! Click <a href="file2.php">here</a> to see them in action.</p>'; } ?> <!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" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title>File1</title> <style type="text/css"> <!-- These are the styles the session (if it exists) should configure --> a:link {color:blue;} a:hover {color:orange;} body {background-color:red} h1 {color:blue; text-align:center;} </style> </head> <body> <?php //if the cookies were sent print a message if (isset($msg)){ print $msg; } ?> <div><p>Please complete this form to configure the appearance of this website:</p> <form action="File2.php" method="post"> <select name="background_color"> <option value="">Background Color</option> <option value="FF6600">Orange</option> <option value="CC00CC">Purple</option> <option value="FFFF00">Yellow</option> <option value="00FF00">Green</option> <option value="FF0066">Pink</option> <option value="000099">Blue</option> </select> <select name="link_color"> <option value="">Link Color</option> <option value="FF6600">Orange</option> <option value="CC00CC">Purple</option> <option value="FFFF00">Yellow</option> <option value="00FF00">Green</option> <option value="FF0066">Pink</option> <option value="000099">Blue</option> </select> <select name="link_hover_color"> <option value="">Link Hover Color</option> <option value="FF6600">Orange</option> <option value="CC00CC">Purple</option> <option value="FFFF00">Yellow</option> <option value="00FF00">Green</option> <option value="FF0066">Pink</option> <option value="000099">Blue</option> </select> <select name="header_color"> <option value="">Header Color</option> <option value="FF6600">Orange</option> <option value="CC00CC">Purple</option> <option value="FFFF00">Yellow</option> <option value="00FF00">Green</option> <option value="FF0066">Pink</option> <option value="000099">Blue</option> </select> <input type="submit" name="submit" value="Configure!" /> </form> </div> </body> </html> file3.php <!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" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title>File3</title> <?php $backgroundcolor = $_COOKIE['background_color']; $linkcolor = $_COOKIE['link_color']; // Define the variable $linkhovercolor = $_COOKIE['link_hover_color']; $headercolor = $_COOKIE['header_color']; ?> <style type="text/css"> <!-- These are the styles the session should configure --> a:link {color:#<?php $linkcolor; ?>} //Use the variable in the style a:hover {color:#<?php $linkhovercolor; ?>} body {background-color:#<?php $backgroudcolor; ?>} h1 {color:#<?php $headercolor; ?> text-align:center;} </style> </head> <body> <div> <h1>Welcome to YOUR pretty website</h1> <a href = "File1.php">Click here</a> to go back and start over!</a> </div> </body> </html>
  8. I'm trying to write a script that allows the user to select their personal settings for the site. They can pick the color of their background, link color, link hover color and the header color. the first file is supposed to use the defaults, blue for the links, orange for the link hover color red for the background and blue for the header. the second file is supposed to configure the cookie variables to store the values entered by the user and the third file i'm supposed to modify the internal stylesheet to utilize the values stored in the session variables. I tried to set each of the values in file two but i think i messed it up. I dont know how to modify the stylesheet to accept and change to the values of the cookies...Please help here are the files file1.php <?php //Handle the form if it has been submitted: if (isset($_POST['background_color'], $_POST['link_color'], $_POST['link_hover_color'], $_POST['header_color'])){ //send the cookies: setcookie('background_color', $_POST['background_color'], time()+10000000); setcookie('link_color', $_POST['link_color'], time()+10000000); setcookie('link_hover_color', $_POST['link_hover_color'], time()+10000000); setcookie('header_color', $_POST['header_color'], time()=10000000); //Message to be printed later: $msg = '<p>Your settings have been entered! Click <a href="file2.php">here</a> to see them in action.</p>'; } ?> <!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" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title>File1</title> <style type="text/css"> <!-- These are the styles the session (if it exists) should configure --> a:link {color:blue;} a:hover {color:orange;} body {background-color:red} h1 {color:blue; text-align:center;} </style> </head> <body> <?php //if the cookies were sent print a message if (isset($msg)){ print $msg; } ?> <div><p>Please complete this form to configure the appearance of this website:</p> <form action="File2.php" method="post"> <select name="background_color"> <option value="">Background Color</option> <option value="FF6600">Orange</option> <option value="CC00CC">Purple</option> <option value="FFFF00">Yellow</option> <option value="00FF00">Green</option> <option value="FF0066">Pink</option> <option value="000099">Blue</option> </select> <select name="link_color"> <option value="">Link Color</option> <option value="FF6600">Orange</option> <option value="CC00CC">Purple</option> <option value="FFFF00">Yellow</option> <option value="00FF00">Green</option> <option value="FF0066">Pink</option> <option value="000099">Blue</option> </select> <select name="link_hover_color"> <option value="">Link Hover Color</option> <option value="FF6600">Orange</option> <option value="CC00CC">Purple</option> <option value="FFFF00">Yellow</option> <option value="00FF00">Green</option> <option value="FF0066">Pink</option> <option value="000099">Blue</option> </select> <select name="header_color"> <option value="">Header Color</option> <option value="FF6600">Orange</option> <option value="CC00CC">Purple</option> <option value="FFFF00">Yellow</option> <option value="00FF00">Green</option> <option value="FF0066">Pink</option> <option value="000099">Blue</option> </select> <input type="submit" name="submit" value="Configure!" /> </form> </div> </body> </html> file2.php <!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" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title>File2</title> </head> <body> <div> <?php include('file1.php'); //check for a background color if (isset($_COOKIE['background_color'])){ print "\body: #" . htmlentities($_COOKIE['background_color']) . ";\n"; }else{ print "\body: #c00"; } //check for a link_color if (isset($_COOKIE['link_color'])){ print "\a:link: #" . htmlentities($_COOKIE['link_color']) . ";\n"; }else{ print "\a:link: #00f"; } //check for a link_hover color: if (isset($_COOKIE['link_hover_color'])){ print "a\:hover: #" . htmlentities($_COOKIE['link_hover_color']) . ";\n"; } //Check for a header color if (isset($_COOKIE['header_color'])){ print "\h1: #" . htmlentities($_COOKIE['header_color']). ";\n"; } ?> Your settings have been updated. <a href="File3.php">Click here</a> to continue. <br /><br /> </div> </body> </html> file3.php <!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" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title>File3</title> <style type="text/css"> <!-- These are the styles the session should configure --> a:link {color:blue;} a:hover {color:orange;} body {background-color:red} h1 {color:blue; text-align:center;} </style> </head> <body> <div> <h1>Welcome to YOUR pretty website</h1> <a href = "File1.php">Click here</a> to go back and start over!</a> </div> </body> </html> I'm pretty sure i did in file2 what i was supposed to do in file3 im totally confused
  9. heres the updated code test1.html <!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" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title>Feedback Form</title> </head> <body> <div><p>Please complete this form to submit your feedback:</p> <form action="test1.php" method="post"> <p>Name: <select name="title"> <option value="Mr.">Mr.</option> <option value="Mrs.">Mrs.</option> <option value="Ms.">Ms.</option> </select> <input type="text" name="name" size="20" /></p> <p>Email Address: <input type="text" name="email" size="20" /></p> <p>Age: <input type="text" name="age" size="20" /></p> <p>Response: This is... <input type="radio" name="response" value="excellent" /> excellent <input type="radio" name="response" value="okay" /> okay <input type="radio" name="response" value="boring" /> boring</p> <p>Comments: <textarea name="comments" rows="3" cols="30"></textarea></p> <input type="submit" name="submit" value="Send My Feedback" /> </form> </div> </body> </html> test1.php <!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" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title>Your Feedback</title> </head> <body> <?php include('test1.html'); $name = $_POST['name']; $age = $_POST['age']; $okay = TRUE; $i = $_POST['age']; if(empty($name)){ echo '<p class="error"> Please enter your name.</p>'; $okay = FALSE; } if (empty($age)){ echo '<p class="error"> Please enter you age.</p>'; $okay = FALSE; } if ($age < 65){ echo '<p>no retirement for you</p>'; } if ($age == 65){ echo '<p> Yay, you can retire</p>'; } if ($age > 65 && $age < 100){ echo '<p>Florida is for me!</p>'; } if ($age > 100){ echo '<p>Good Genes</p>'; } //print users age to 1000 by 3s for($i=$age; $i<1000;$i+3){ echo $age; } ?> </body> </html>
  10. now it prints out the users age, but it won't increment by 3s
  11. okay, now it prints out $age$age$age$age$age$age$age$age$age$age$age$age$age$age$age$age$age$age$age$age$age$age$age infinitely
  12. right, but i keep getting error messages $age Notice: Use of undefined constant i - assumed 'i' in C:\xampp\htdocs\xampp\PHP\test1.php on line 38 $age Notice: Use of undefined constant i - assumed 'i' in C:\xampp\htdocs\xampp\PHP\test1.php on line 38 $age Notice: Use of undefined constant i - assumed 'i' in C:\xampp\htdocs\xampp\PHP\test1.php on line 38 $age Notice: Use of undefined constant i - assumed 'i' in C:\xampp\htdocs\xampp\PHP\test1.php on line 38 $age Notice: Use of undefined constant i - assumed 'i' in C:\xampp\htdocs\xampp\PHP\test1.php on line 38 $age
  13. I have this script that asks the user their name and email address and age and stuff and it checks to see what their age is and outputs a message depending on what age bracket they belong to. I am trying to make a for loop that uses the value the user submitted for their age and output the range of numbers from the users age to 1000 by 3s, i know how the basic for loop works, but i don't know how to do one where you are using a variable for i. if that makes sense. Heres the code that i have. test1.html <!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" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title>Feedback Form</title> </head> <body> <div><p>Please complete this form to submit your feedback:</p> <form action="test1.php" method="post"> <p>Name: <select name="title"> <option value="Mr.">Mr.</option> <option value="Mrs.">Mrs.</option> <option value="Ms.">Ms.</option> </select> <input type="text" name="name" size="20" /></p> <p>Email Address: <input type="text" name="email" size="20" /></p> <p>Age: <input type="text" name="age" size="20" /></p> <p>Response: This is... <input type="radio" name="response" value="excellent" /> excellent <input type="radio" name="response" value="okay" /> okay <input type="radio" name="response" value="boring" /> boring</p> <p>Comments: <textarea name="comments" rows="3" cols="30"></textarea></p> <input type="submit" name="submit" value="Send My Feedback" /> </form> </div> </body> </html> test1.php <!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" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title>Your Feedback</title> </head> <body> <?php include('test1.html'); $name = $_POST['name']; $age = $_POST['age']; $okay = TRUE; if(empty($name)){ echo '<p class="error"> Please enter your name.</p>'; $okay = FALSE; } if (empty($age)){ echo '<p class="error"> Please enter you age.</p>'; $okay = FALSE; } if ($age < 65){ echo '<p>no retirement for you</p>'; } if ($age == 65){ echo '<p> Yay, you can retire</p>'; } if ($age > 65 || $age < 100){ echo '<p>Florida is for me!</p>'; } if ($age > 100){ echo '<p>Good Genes</p>'; } //print users age to 1000 by 3s for($i=$age; $<1000 i+3){ echo '$age'; } ?> </body> </html>
×
×
  • 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.