textarea in php

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
dheeraj
Forum Commoner
Posts: 40
Joined: Fri Feb 06, 2009 11:54 am

textarea in php

Post by dheeraj »

hello i m a newbie in php & i m crushing my mind in textarea, i want to submit value of textarea to another page, but when i send it its format got change my code is like a below one

Code: Select all

<form id="form1" name="form1" method="post" action="test2.php">
  <textarea name="ta" cols="60" rows="6" id="ta"><p align="justify"></textarea>
  <input type="submit" name="Submit" value="Submit" />
</form>
test2.php

Code: Select all

<textarea name="textarea" cols="60" rows="6"><?php echo $_POST['ta'];?></textarea>
its output should come as <p align="justify">

but its coming <p align=/"justify/">

so plz help me...
mickeyunderscore
Forum Contributor
Posts: 129
Joined: Sat Jan 31, 2009 9:00 am
Location: UK

Re: textarea in php

Post by mickeyunderscore »

You probably have magic_quotes enabled: http://uk2.php.net/magic_quotes

You should disable it, or run stripslashes() on your $_POST variable e.g.:

Code: Select all

<?php echo stripslashes($_POST['ta']);?>
User avatar
dheeraj
Forum Commoner
Posts: 40
Joined: Fri Feb 06, 2009 11:54 am

Re: textarea in php

Post by dheeraj »

ohhhhhhh really thank u, thank u very much both options hd worked..

thank u...

there is one more problem ....
i want a combo box having values 1, 2 & 3 & having item label india, usa & england like below

Code: Select all

<select name="select">
<option value="1">india</option>
<option value="2">usa</option>
<option value="3">england</option>
now the question is tht how to retrive values & item label both at another page..

if i put

Code: Select all

<?php echo $_POST['select'];?>
then the output will be 1, 2 or may be 3 depend on selection, but if i want item label thn wht to do....
mickeyunderscore
Forum Contributor
Posts: 129
Joined: Sat Jan 31, 2009 9:00 am
Location: UK

Re: textarea in php

Post by mickeyunderscore »

You can't retrieve the label via $_POST, only the value. You would need to change your select box code to:

Code: Select all

<option value="india">india</option>
<option value="usa">usa</option>
<option value="england">england</option>
User avatar
dheeraj
Forum Commoner
Posts: 40
Joined: Fri Feb 06, 2009 11:54 am

Re: textarea in php

Post by dheeraj »

okkkkk again thanx ur help is apreciable...
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: textarea in php

Post by Benjamin »

Forum Rules wrote: 11. Please use proper, complete spelling when posting in the forums. AOL Speak, leet speak and other abbreviated wording can confuse those that are trying to help you (or those that you are trying to help). Please keep in mind that there are many people from many countries that use our forums to read, post and learn. They do not always speak English as well as some of us, nor do they know these aberrant abbreviations. Therefore, use as few abbreviations as possible, especially when using such simple words.
viewtopic.php?f=6&t=30037
Post Reply