php - Text Area spacing when inserting to database -
so have text area wherein data posted database.
so here image of sample input might like.it has spacing via enter key when send database spacing wont there , display of input
<?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
Post a Comment