Jump to content

king94@

New Members
  • Posts

    9
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

king94@'s Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. NEW PAGE 2 WITH LINK TO PAGE 3: When it displays page 2, the link text and the inputtext both appear (correctly) but both as a link to page 3????? So that means it is going through the if statement but also going outside the if statement???? I cannot understand how it is doing that. <?php ob_start(); //Start output buffer for the header() to work. if ($_POST['pref']=='y') { setcookie('font', $_POST['font'], time()+60*20); setcookie('size', $_POST['size'], time()+60*20); setcookie('color', $_POST['color'], time()+60*20); setcookie('inputtext', $_POST['inputtext'], time()+60*20); header('page3c2q5.php'); //LINK TO PAGE 3: echo "<a href='page3c2q5.php'>"; echo "Click here to see information"; } ?> <?php //PASS AND ACCESS THE VARIABLES THROUGH THE SESSION NORMALLY (NO COOKIE USE HERE): session_start(); $_SESSION['inputtext'] = $_POST['user']; $_SESSION['font'] = $_POST['font']; $_SESSION['size'] = $_POST['size']; $_SESSION['color'] = $_POST['color']; echo "<font face='"; echo $_SESSION['font']; echo "' size='"; echo $_SESSION['size']; echo "' color='"; echo $_SESSION['color']; echo "'>"; echo $_SESSION['inputtext']; echo "</font>"; ?> Page 3 is still blank.
  2. My new PAGE 2 : <?php ob_start(); //Start output buffer for the header() to work. if ($_POST['pref']=='y') { setcookie('font', $_POST['font'], time()+60*20); setcookie('size', $_POST['size'], time()+60*20); setcookie('color', $_POST['color'], time()+60*20); setcookie('inputtext', $_POST['inputtext'], time()+60*20); header('page3c2q5.php'); } //PASS AND ACCESS THE VARIABLES THROUGH THE SESSION NORMALLY (NO COOKIE USE HERE): session_start(); $_SESSION['inputtext'] = $_POST['user']; $_SESSION['font'] = $_POST['font']; $_SESSION['size'] = $_POST['size']; $_SESSION['color'] = $_POST['color']; echo "<font face='"; echo $_SESSION['font']; echo "' size='"; echo $_SESSION['size']; echo "' color='"; echo $_SESSION['color']; echo "'>"; echo $_SESSION['inputtext']; echo "</font>"; ?> When i get to page 2, it outputs everything correctly, but bypasses the if statement! PAGE 3 (I called it 3c2q5): ( I DID NOT create link from page 2 to page 3, is it necessary? <?php echo "<font face='"; echo $_COOKIE['font']; echo "' size='"; echo $_COOKIE['size']; echo "' color='"; echo $_COOKIE['color']; echo "'>"; echo $_COOKIE['inputtext']; echo "</font>"; ?> Page 3 is blank, there is no output. Was worth a try.
  3. Thanks for your patience, I am trying it out right now.
  4. Thanks for the advice. This is so confusing. No idea how to fix. Will keep trying stuff. So if i take out: $_COOKIE['inputtext'] = $_POST['user']; $_COOKIE['font'] = $_POST['font']; $_COOKIE['size'] = $_POST['size']; $_COOKIE['color'] = $_POST['color']; And take out: echo "<font face='"; echo $_COOKIE['font']; echo "' size='"; echo $_COOKIE['size']; echo "' color='"; echo $_COOKIE['color']; echo "'>"; echo $_COOKIE['inputtext']; echo "</font>"; Then create a link to a third page, and basically put: echo "<font face='"; echo $_COOKIE['font']; echo "' size='"; echo $_COOKIE['size']; echo "' color='"; echo $_COOKIE['color']; echo "'>"; echo $_COOKIE['inputtext']; echo "</font>"; It should work??? Am I on the right track?
  5. Thank you Oni for your post. There is a problem: Problem is: the script works but it is not using the cookie as it is supposed to, here is how i know this: First i deleted below: $_COOKIE['inputtext'] = $_POST['user']; $_COOKIE['font'] = $_POST['font']; $_COOKIE['size'] = $_POST['size']; $_COOKIE['color'] = $_POST['color']; I wanted to check if it would work without it, it DID NOT WORK. So i kept it. Then I started deleting individual lines from: setcookie('font', '$_POST['font'], time()+60); setcookie('size', '$_POST['size'], time()+60); setcookie('color', '$_POST['color'], time()+60); <---DELETED THIS LINE setcookie('inputtext', '$_POST['inputtext'], time()+60); <--- DELETED THIS LINE The script still worked despite deleting the cookie entries. Please correct me if i am wrong but doesn't that mean that the following lines: $_COOKIE['inputtext'] = $_POST['user']; $_COOKIE['font'] = $_POST['font']; $_COOKIE['size'] = $_POST['size']; $_COOKIE['color'] = $_POST['color']; are acting like sessions and not cookies? I understand $_COOKIE to be a variable just like $_SESSION[.....] BOTTOM LINE: I think the input is being accessed through sessions regardless of whether the box is checked on page 1.
  6. Hi there, I need some help again. This is a continuation of a question i asked earlier. Initially the question stated: write a program that formats ablock of text (to be input by the user) based on preferences chosen by the user. Give your user options for color of text, font choice, and size. Display the output on a new page. DID THAT ALL. Now HERE is the part i am stuck on: it says: now allow the user the option of saving the information for the next time they visit, and if they choose "yes", save the information in a COOKIE! PAGE 1 (FORM INPUT): <?php session_unset(); ?> <html> <head> <title>CHAPTER 2, QUESTION 4</title> </head> <body> <form method = "post" action = "chap2q5endresult.php"> <p>Enter you font chice: <select name="font"> <option value="Verdana">Verdana</option> <option value="Arial">Arial</option> <option value="Times New Roman">Times New Roman</option> </select> </p> <p>Enter your font size: <select name="size"> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> </select> </p> <p>Enter your font colour: <select name="color"> <option value="black">Black</option> <option value="red">Red</option> <option value="green">Green</option> <option value="purple">Purple</option> </select> </p> <p>Enter your text here: <input type = "textarea" font ="font" size="size" name ="user"> </p> <p>Do you want to save these preferences for the next time you log in? //THIS IS WHAT I ADDED FOR PAGE 1.<<<<<-------------- <input type="checkbox" name="pref" value="y"> </p> <input type="submit" name="Submit" value="Submit"> </form> </body> </html> PAGE 2: DISPLAYING INPUT FROM PAGE 1: (PROBLEM PAGE). Error message keeps saying parse error for line 17 which is setcookie(.........) group. <?php //OK, SO ALL THE INPUT INFO WAS SENT BY POST TO THIS SECOND PAGE if ($_POST['pref']=='y') { //THE IF STATEMENT IS TO VERIFY IF CHECKBOX FOR SAVING PREFERENCES WAS CHECKED. //DO NOT THINK I NEED THIS STUFF BELOW: $_COOKIE['inputtext'] = $_POST['user']; $_COOKIE['font'] = $_POST['font']; $_COOKIE['size'] = $_POST['size']; $_COOKIE['color'] = $_POST['color']; //POSSIBLY DELETE 4 LINES ABOVE!!! //BELOW I AM ASSIGNING THE VALUES FROM PREVIOUS FORM, GIVING THEM NAMES: font, size, color, inputtext, //AND STORING IN COOKIE setcookie('font', '$_POST['font'], time()+60); setcookie('size', '$_POST['size'], time()+60); setcookie('color', '$_POST['color'], time()+60); setcookie('inputtext', '$_POST['inputtext'], time()+60); //NOT SURE IF I NEED TO STORE INPUTTEXT IN COOKIE, I THINK NOT?! //BELOW I AM ACCRESSING THE INFO STORED IN THE COOKIE: //I AM NOT SURE IF I NEED TO PRE-DEFINE THE $_COOKIE VARIABLE, WHICH IS WHY //I EQUATED THE $_COOKIE VARIABLES TO $_POST AT THE TOP OF PAGE (UP TOP) echo "<font face='"; echo $_COOKIE['font']; echo "' size='"; echo $_COOKIE['size']; echo "' color='"; echo $_COOKIE['color']; echo "'>"; echo $_COOKIE['inputtext']; echo "</font>"; } //IF THE IF STATEMENT IS NOT TRUE DO THE FOLLOWING: else{ //PASS AND ACCESS THE VARIABLES THROUGH THE SESSION NORMALLY (NO COOKIE USE HERE): session_start(); $_SESSION['inputtext'] = $_POST['user']; $_SESSION['font'] = $_POST['font']; $_SESSION['size'] = $_POST['size']; $_SESSION['color'] = $_POST['color']; echo "<font face='"; echo $_SESSION['font']; echo "' size='"; echo $_SESSION['size']; echo "' color='"; echo $_SESSION['color']; echo "'>"; echo $_SESSION['inputtext']; echo "</font>"; } ?> THANK YOU FOR ANY HELP, THANK YOU FOR YOUR TIME.
  7. SOLVED!!! Thank you merck, you are the best. So happy. Thank you all very much for all your help. I am very grateful. Take care.
  8. I re-edited PAGE 2 but still cannot get text to change to settings. AAAAAAAAAAAAAARRRRGGGHHHHH! Appreciate the help deadlyp99 but it still does not work! RE-EDITED PAGE 2: <?php session_start(); $_SESSION['inputtext'] = $_POST['user']; $_SESSION['font'] = $_POST['font']; $_SESSION['size'] = $_POST['size']; $_SESSION['color'] = $_POST['color']; ?> <?php echo "<font face='"; echo $_SESSION['font']; echo "' size='"; echo $_SESSION['size']; echo "' color='"; echo $_SESSION['color']; echo "'>"; echo $_SESSION['inputtext']; echo "</font>"; ?>
  9. I would really appreciate some help, i am teaching myself php, it is going well. I am having trouble understanding how to do this question: Write a program that formats a block of text (to be input by the user) based on preferences chosen by the user. Give your user options for color of text, font choice, and size. display the output on a new page. (from wrox company: php5, apache and MySQL web development) I have created 2 pages, i think i am half way right. I cannot understand how to display the text on the 2nd page with all the settings chosen???!!! 1st PAGE (FORM): <?php session_unset(); ?> <html> <head> <title>CHAPTER 2, QUESTION 4</title> </head> <body> <p>Enter you font choice: <select name="font"> <option value="Verdana">Verdana</option> <option value="Arial">Arial</option> <option value="Times New Roman">Times New Roman</option> </select> </p> <p>Enter your font size: <select name="size"> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> </select> </p> <p>Enter your font colour: <select name="color"> <option value="black">Black</option> <option value="red">Red</option> <option value="green">Green</option> <option value="purple">Purple</option> </select> </p> <form method = "post" action = "chap2q4endresult.php"> <p>Enter your text here: <input type = "textarea" font ="font" size="size" name = "user"> </p> <input type="submit" name="Submit" value="Submit"> </form> </body> </html> 2nd PAGE (DISPLAYING TEXT FROM TEXTAREA) PROBLEM PART!!!! : <?php session_start(); $_SESSION['inputtext'] = $_POST['user']; $_SESSION['font'] = $_POST['font']; $_SESSION['size'] = $_POST['size']; $_SESSION['color'] = $_POST['color']; echo "<font face='"; echo $_SESSION['font']; echo "' size='"; echo $_SESSION['size']; echo "'color='"; echo $_SESSION['color']; echo "'>"; echo $_SESSION['inputtext']; ?> ANY ADVICE WOULD BE GREATLY APPRECIATED, THANK YOU FOR YOUR TIME.
×
×
  • 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.