Jump to content

[SOLVED] how to add <br> in <textarea> output


vinpkl

Recommended Posts

hi all

 

i would like to ask that i have a <textarea> and in that i can insert 3 lines.

If the content is entered with "pressing enter" after each line then i want that 3 lines ouput should come with a break after each line. means i just want to add <br> after each line ouput.

the name of <textarea> is shipping_detail.

 

$shipping_detail=$_REQUEST['shipping_detail'];

 

vineet

Link to comment
Share on other sites

Can you post your code that is sent after submit?

 

hi

 

here is the code

 


if(isset($_REQUEST['submit']))
{	
$shipping_detail=$_REQUEST['shipping_detail'];
$warranty=$_REQUEST['warranty'];

$insertqry="insert into product_table(shipping_detail,warranty) values('$shipping_detail','$warranty')";

if(mysql_query($insertqry))
$msg="shipping Product added successfully";
else
$msg="Error Inserting new product";
}

 

Here is the result

--------------------

3-7 days shipping. Product shipped from delhi.

----------------------

 

I want to insert <br> before Product word starts

Link to comment
Share on other sites

I assume shipping details is:

 

123 Street

2nd Address

SomeWhere, ST 12345

 

I don't have a lot of stars by my name but this is how I handle address info.

 

It makes validation easier also.

 

<?

if(isset($_POST['submit']))
{	
$Street1=$_REQUEST['Street1'];
$Street2=$_REQUEST['Street2'];
$City=$_REQUEST['City'];
$State=$_REQUEST['State'];
$Zip=$_REQUEST['Zip'];


/** put your insert code here **/

echo $Street1; 
echo $Street2;  
echo $City;
echo $Zip;  

/** end your insert code here **/


}

?>

<form action='' method=post>
<input name='Street1' size=40 /><br />
<input name='Street2' size=40 /><br />
<input name='City' size=20 /><input name='State'  size=2/><input name='Zip' size=9 />
<br /><br />
<input type=submit name=submit value=submit>
</form>

Link to comment
Share on other sites

I assume shipping details is:

 

123 Street

2nd Address

SomeWhere, ST 12345

 

I don't have a lot of stars by my name but this is how I handle address info.

 

It makes validation easier also.

 

<?

if(isset($_POST['submit']))
{	
$Street1=$_REQUEST['Street1'];
$Street2=$_REQUEST['Street2'];
$City=$_REQUEST['City'];
$State=$_REQUEST['State'];
$Zip=$_REQUEST['Zip'];


/** put your insert code here **/

echo $Street1; 
echo $Street2;  
echo $City;
echo $Zip;  

/** end your insert code here **/


}

?>

<form action='' method=post>
<input name='Street1' size=40 /><br />
<input name='Street2' size=40 /><br />
<input name='City' size=20 /><input name='State'  size=2/><input name='Zip' size=9 />
<br /><br />
<input type=submit name=submit value=submit>
</form>

 

hi

 

well its not address its detail about shipping, how many days wil it take, from where product will be shipped, about courier and all that.

it can be 3 lines, may be 5 or 6. thats why i have inserted <textarea>.

 

Here is the result

--------------------

3-7 days shipping. Product shipped from delhi.

----------------------

I want to insert <br> before Product word starts.

 

if i didnt get any solution for <textarea> then i have to adopt your solution.

 

 

vineet

Link to comment
Share on other sites

This will handle the breaks the quotes the single quotes...

 

if(isset($_POST['submit']))
{	
$info=$_REQUEST['info'];
$info=stripslashes($_POST['info']);
$info=htmlentities($info, ENT_QUOTES);
$info=nl2br($info);


/** put your insert code here **/

echo $info; 


/** end your insert code here **/


}

?>

<form action='' method=post>
<textarea name=info rows="5" cols="36"></textarea>
<input type=submit name=submit value=submit>
</form>

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.