Jump to content

Recommended Posts

$usertxt=$_POST['usertxt'];

$font=$_POST['font'];

$size=$_POST['size'];

$color=$_POST['color'];

 

These are my variables brought over from a page that is below:

 

<form method="post" action="displaytext.php">

<p>What text would you like changed?<input type="text" name="usertxt" />

</p>

<p>Enter your font

<select name="font">

<option value="Verdana">Verdana</option>

<option value="Times New Roman">Times New Roman</option>

<option value="Arial">Arial</option>

<option value="Comic Sans">Comic Sans</option>

</select>

<p>Select 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>Select the color you would like<select name="color">

<option value="red">Red</option>

<option value="blue">Blue</option>

<option value="green">Green</option>

<option value="yellow">Yellow</option>

</select>

<P><input type="submit" name="Submit" value="Submit" />

 

The variables have the correct data in them, I checked.

How can I show the inputted text in the size, font and color the user chose?

I tried echo command but don't know how to structure. Thanks.

The echo showed the proper contents of the variables. I actually solved this. To set the style of what the user chose, I used:

 

<style type="text/css">

p {color:<?php echo $color; ?>; font:<?php echo $font; ?>; font-size:<?php echo $fontsize; ?>%}

</style>

I went back and changed the 1,2,3,4 for font size to 50, 100, 150, 200

I then used htmlspecialchars to output with css styling:

 

Here is your text:

<p><?php echo htmlspecialchars($usertxt); ?></p>

And it all worked!

I am a newbie, so getting the stuff to do what I want is challenging, but at least there are functions to accomplish it.

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.