I have a form that I can post. I also have a sql database that it has a successful connection with. However, when I close the page out, the user input disappears. How can I make the user input part of the page content,almost like a guestbook kind of idea?
<p onclick="myFunction()">Click here to share your personal testimony</p>
<div id="formwindow">
<form action="http://needjesuskneadjesus.org/perstest.php" method="post">
Name: <input type="text" name="name">
<span class="error">* <?php echo $nameErr; ?></span>
<br>
Email: <input type="text" name="email">
<span class="error">* <?php echo $emailErr; ?></span>
<br>
Personal Testimony:<br> <textarea name="personalTestimony" rows="10" cols="50"></textarea><br>
<input type="Submit">
</form>
</div>
<script>
function myFunction() {
document.getElementById("formwindow").style.display = "block";
}
</script>
</br>
<?php
echo "Name: " . $_POST['name'];
?>
</br>
<?php
echo "Email: " . $_POST['email'];
?>
</br>
<?php
echo "Personal Testimony: " . $_POST['personalTestimony'];
?>
</br>
/* Attempt MySQL server connection.
// Check connection
if($link === false){
die("ERROR: Could not connect. " . mysqli_connect_error());
}
// Escape user inputs for security
$name = mysqli_real_escape_string($link, $_REQUEST['name']);
$email = mysqli_real_escape_string($link, $_REQUEST['email']);
$personalTestimony = mysqli_real_escape_string($link,
$_REQUEST['personalTestimony']);
// attempt insert query execution
$sql = "INSERT INTO personalTestimony (name, email, testimony) VALUES
('$name', '$email', '$personalTestimony')";
if(mysqli_query($link, $sql)){
echo "Thanks for sharing your personal testimony.";
} else{
echo "ERROR: Could not able to execute $sql. " . mysqli_error($link);
}
// close connection
mysqli_close($link);
*/
?>