I can't get it right from my previous question so I explain it here more further.
This is my index.php and that's the method I used to save it to database
<html>
<head>
<script>
function updategroup()
{
var update_con=document.getElementsByName("update_con")[0].value.replace(/\\
/g, "<br />");
var xmlhttp;
if(update_con == "" || update_con == " ")
{
alert("Box is empty");
return;
}
else{
if (window.XMLHttpRequest)
{
xmlhttp=new XMLHttpRequest();
}
else
{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("groups").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","fors.php?update_con="+update_con,true);
xmlhttp.send();}
}
</script>
</head>
<body>
<textarea name="update_con" rows="5" cols="50" >
</textarea>
<button onclick="updategroup()" >click</button>
<div id="groups" ><?php include("updates.php"); ?></div>
</body>
</html>
The line
var update_con=document.getElementsByName("update_con")[0].value.replace(/ /g, "
");
I used to replace nl to br. Am I get it right? I guess not.
this is the fors.php
<?php
include("conn2.php");
$update_con = $_GET["update_con"];
$query_fors = "INSERT INTO updates(update_con) VALUES('$update_con')";
mysql_query($query_fors);
include("updates.php");
?>
And finally, my updates.php
<?php
include("conn2.php");
$query_sel = mysql_query("SELECT * FROM updates");
while($rows_sel = mysql_fetch_assoc($query_sel)){
$update_con = $rows_sel['update_con'];
//echo "<div style='border: 1px solid #000;' >$update_con</div><br />";
echo nl2br(htmlspecialchars($update_con))."<br />";
}
?>
I used the line echo nl2br(htmlspecialchars($update_con))
for displaying it. And when I enter texts inside the textarea with newlines, I only get a straight texts,without breaks,without newlines.... And when I open 'updates' table inside 'fors' database. I couldn't see texts with newlines like I enter into textarea. Thanks in advance :)
I don't want my database to hold any html tags :)