My goal is to extract each line from a textarea and save it to my mysql db.
I think my problem lies within the AJAX function or the part, where I get the lines from the textarea, but see yourself:
//#userip = textarea;
var content = $("#user_ip").val();
var ips = content.split("\n");
$.ajax({
type: 'POST',
url: 'inc.php?ban_user',
data: 'user_ip='+ips,
dataType: 'html',
success: function(data) {
alert(data);
},
error: function() {
alert("Error");
}
});
And the PHP part is:
if (isset($_POST["user_ip"])) {
$user_ip = htmlspecialchars(trim($_POST["user_ip"]));
mysql_query("INSERT into banned (ip) values ('$user_ip')") or die(mysql_error());
echo($user_ip);
}
At this point $user_ip seems to be just one string of all textarealines combined.
I know that this way the php code above wont work and it will save all lines as one result!
What I want: Save each txtarea-line seperatly in my db.
“data” attribute want an object with “attribute”:value pairs, and your give him a string.