Reputation: 27
I have make a form with this code:
<form action="action.php" method="POST">
HTML:
<textarea name="html"></textarea>
<input type="submit">
</form>
and Insert it with php :
<?php
include "database.php";
$html = mysqli_real_escape_string($connect, $_POST['html']);
$insert = mysqli_query($connect, "INSERT INTO data VALUES('$html')");
?>
I have used that, and it successfully inserted to mysql, but some of my html string is missing Example: if i insert 2000 character of html, it just insert 250 character Note: I'm using jquery to post the form
$.ajax({
url : url_login,
data : 'html='+html,
type : 'POST',
dataType: 'html',
success : function(mess){
$('#content').html(mess);
},
});
Please help
Upvotes: 1
Views: 78
Reputation: 14550
You should follow the format as mentioned by jQuery AJAX documentation:
change,
data : 'html='+html,
to,
data : {
html: html
}
The format that is being use is known as a object where you specify key/values (as many as you'd like).
Note
mysqli_*
consider usng prepared
statements to prevent
SQL injection.$_POST
with isset
and empty
to ensure that the fields are set to prevent errors.Upvotes: 1