Here is an example on text that has been pasted into a textarea and then posted to database:
This text gets passed from textarea to database:
Theodore John Kaczynski (/kəˈzɪnski/; born May 22, 1942), also known as the Unabomber (/ˈjuːnəbɒmər/), is an American domestic terrorist, anarchist, and former mathematics professor.[2][3][4] He was a mathematics prodigy,[5] but he abandoned his academic career in 1969 to pursue a more primitive lifestyle. Between 1978 and 1995, he killed three people and injured 23 others in an attempt to start a revolution by conducting a nationwide bombing campaign targeting people involved with modern technology. In conjunction with this effort, he issued a social critique opposing industrialization while advocating a nature-centered form of anarchism.[6]
In 1971, Kaczynski moved to a remote cabin without electricity or running water near Lincoln, Montana, where he lived as a recluse while learning survival skills in an attempt to become self-sufficient. He witnessed the destruction of the wilderness surrounding his cabin and concluded that living in nature was untenable; he began his bombing campaign in 1978. In 1995, he sent a letter to The New York Times and promised to "desist from terrorism" if the Times or The Washington Post published his essay Industrial Society and Its Future, in which he argued that his bombings were extreme, but necessary to attract attention to the erosion of human freedom and dignity by modern technologies that require large-scale organization.
This text doesn't get passed from textarea to database:
Kaczynski was the subject of the longest and most expensive investigation in the history of the Federal Bureau of Investigation. Before his identity was known, the FBI used the case identifier UNABOM (University and Airline Bomber) to refer to his case, which resulted in the media naming him the "Unabomber". The FBI and Attorney General Janet Reno pushed for the publication of Industrial Society and Its Future, which led to a tip from Kaczynski's brother David, who recognized the writing style.
After his arrest in 1996, Kaczynski tried unsuccessfully to dismiss his court-appointed lawyers because they wanted him to plead insanity in order to avoid the death penalty, whereas he did not believe that he was insane. In 1998, a plea bargain was reached under which he pleaded guilty to all charges and was sentenced to life in prison without possibility of parole.
And one last thing. ASCII art wont also be passed to database.
Here's my code:
<?php
date_default_timezone_set('Europe/Oslo');
include 'include/dbh_post.inc.php';
include 'include/post.inc.php';
if (isset($_SESSION['userid'])) {
$userid = $_SESSION['userid'];
$username = $_SESSION['username'];
}
else {
$userid = 0;
$username = 'Anonymous';
}
echo"<form method='POST' action'".setPost($conn)."'>
<div style='display: grid; grid-template-columns: 1fr; overflow: hidden; box-sizing: border-box; margin-top: 10px; width: 100%; padding: 0.4em; padding-bottom: 0px; border: solid 2px; border-radius: 5px;'>
<input type='hidden' name='idUsers' value='".$userid."'>
<input type='hidden' name='date' value='".date('Y-m-d H:i:s')."'>
<textarea maxlength='300' name='title' placeholder='Title' rows='2' style='width: 100%; box-sizing: border-box; border-radius: 4px; background-color: #f2eecb;'></textarea>
<div style='padding-top: 0.25em;'>
<textarea maxlength='50000' name='post' placeholder='Text' rows='20' style='width: 100%; box-sizing: border-box; border-radius: 4px; background-color: #f2eecb;'></textarea>
</div>
<div style='margin-top: 0.1em; margin-bottom: 0.1em; text-align: center; line-height: 2;'>
<h1 class='signuptext' style='float: left;'>Status:".$username."</h1>
<button type='submit' name='postSubmit' class='post'>Post</button>
<div>
</div>
</form>";
?>
function setPost($conn) {
if (isset($_POST['postSubmit'])) {
if (isset($_SESSION['userid'])) {
$idUsers = $_SESSION['userid'];
$sql1 = "SELECT * FROM post WHERE idUsers='$idUsers' ORDER BY date DESC LIMIT 1";
$result1 = $conn->query($sql1);
while ($row = $result1->fetch_assoc()) {
$lastTime = strtotime($row['date']);
}
$now = time();
$interval = abs($lastTime - $now);
$minutes = round($interval / 60);
if ($minutes >= 0) {
$idUsers = $_POST['idUsers'];
$date = date('Y-m-d H:i:s');
$title = $_POST['title'];
$post = $_POST['post'];
$one = '1';
$zero = '0';
$sql = "INSERT INTO post (idUsers, date, title, post, report, save, views, upvote, downvote, tru, fals) VALUES ('$idUsers', '$date', '$title','$post', '$zero', $one, '$one', '$one', '$one', '$one', '$one')";
$result = $conn->query($sql);
echo "<script type='text/javascript'>alert('Article successfully posted');history.go(-1);</script>";
}
elseif ($minutes < 5) {
$minutes = 5 - $minutes;
$message = "You have to wait $minutes minutes.";
echo "<script type='text/javascript'>alert('$message');history.go(-1);</script>";
}
}
else {
$message = "You can create articles if you have an account";
echo "<script type='text/javascript'>alert('$message');</script>";
}
}
}