king94@ Posted August 25, 2009 Share Posted August 25, 2009 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. Link to comment https://forums.phpfreaks.com/topic/171714-solved-php-noob-please-help-me-with-form-input-choose-font-size-and-color-help/ Share on other sites More sharing options...
merck_delmoro Posted August 25, 2009 Share Posted August 25, 2009 use this code <?php echo "<font color=".$_POST['color']." size=".$_POST['size']." face = ".$_POST['font'].">".$_POST['inputtext']."</font>" ?> or try to use JavaScript Link to comment https://forums.phpfreaks.com/topic/171714-solved-php-noob-please-help-me-with-form-input-choose-font-size-and-color-help/#findComment-905469 Share on other sites More sharing options...
deadlyp99 Posted August 25, 2009 Share Posted August 25, 2009 Try these changes: name = "user"> change to name="user"> Add your "choices" to be within your form tags echo "'>"; echo $_SESSION['inputtext']; Change to echo "'>"; echo $_SESSION['inputtext']; echo "</font>"; Link to comment https://forums.phpfreaks.com/topic/171714-solved-php-noob-please-help-me-with-form-input-choose-font-size-and-color-help/#findComment-905472 Share on other sites More sharing options...
merck_delmoro Posted August 25, 2009 Share Posted August 25, 2009 @deadlyp99 you didn't done anything that can help mr King94 you only erase space on the code but it doesn't affects the output Link to comment https://forums.phpfreaks.com/topic/171714-solved-php-noob-please-help-me-with-form-input-choose-font-size-and-color-help/#findComment-905479 Share on other sites More sharing options...
king94@ Posted August 25, 2009 Author Share Posted August 25, 2009 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>"; ?> Link to comment https://forums.phpfreaks.com/topic/171714-solved-php-noob-please-help-me-with-form-input-choose-font-size-and-color-help/#findComment-905485 Share on other sites More sharing options...
merck_delmoro Posted August 25, 2009 Share Posted August 25, 2009 I have change your Page 1 You miss place your form tag on your code the font, size,color was not place inside the form tag that's why they not been post on your Page 2 <html> <head> <title>CHAPTER 2, QUESTION 4</title> </head> <body> <form method = "post" action = "chap2q4endresult.php"> <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> <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> Link to comment https://forums.phpfreaks.com/topic/171714-solved-php-noob-please-help-me-with-form-input-choose-font-size-and-color-help/#findComment-905488 Share on other sites More sharing options...
deadlyp99 Posted August 25, 2009 Share Posted August 25, 2009 What I told him to do worked just fine, and I know because I actually tested it. Please don't make snide remarks when you've not tested the changes yourself, thank you. The first change, would not effect the output but its good structure. Second change was his first problem, the submitted data wasn't in the form and was therefore not being sent to the second page. The third change was the font tag was not closed Link to comment https://forums.phpfreaks.com/topic/171714-solved-php-noob-please-help-me-with-form-input-choose-font-size-and-color-help/#findComment-905491 Share on other sites More sharing options...
king94@ Posted August 25, 2009 Author Share Posted August 25, 2009 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. Link to comment https://forums.phpfreaks.com/topic/171714-solved-php-noob-please-help-me-with-form-input-choose-font-size-and-color-help/#findComment-905494 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.