imstylin1 Posted November 21, 2012 Share Posted November 21, 2012 $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. Link to comment https://forums.phpfreaks.com/topic/270985-how-do-i-print-inputted-text-with-user-choices/ Share on other sites More sharing options...
deoiub Posted November 21, 2012 Share Posted November 21, 2012 echo is how you output the contents of a variable. What happened when you tried it? Link to comment https://forums.phpfreaks.com/topic/270985-how-do-i-print-inputted-text-with-user-choices/#findComment-1394098 Share on other sites More sharing options...
imstylin1 Posted November 21, 2012 Author Share Posted November 21, 2012 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. Link to comment https://forums.phpfreaks.com/topic/270985-how-do-i-print-inputted-text-with-user-choices/#findComment-1394106 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.