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.

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>";

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>";

?>

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>

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

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.