Jump to content

[SOLVED] PHP NOOB: Please help me with FORM input (choose font, size and color) HELP


king94@

Recommended Posts

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
Share on other sites

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
Share on other sites

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.