php - Text Area spacing when inserting to database -


so have text area wherein data posted database.

enter image description here

so here image of sample input might like.it has spacing via enter key when send database spacing wont there , display of input

enter image description here

<?php     require("common.php");     if(empty($_session['user']))     {         header("location: login.php");         die("redirecting login.php");     } ?> <?php  $host="localhost"; $username="root"; $password="";  $db_name="phplogin";  $tbl_name="tasks";   mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select db");  $ttoday=$_post['comment1']; $task_issues=$_post['comment2']; $ttom=$_post['comment3']; $id=$_post['comment'];  $sql="insert $tbl_name(task_today, issues, task_tom, u_id)values('$ttoday', '$task_issues', '$ttom', '$id')"; $result=mysql_query($sql);  if($result){ header("location: private.php"); exit; }  else { echo "error"; } ?>  <?php // close connection mysql_close(); ?>   

here insert codes.

use nl2br(). try this,

$ttoday= nl2br($_post['comment1']);


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -