Hey
edpro.php
<center>
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
// collect value of input field
$data = $_REQUEST['comment'];
if (empty($data)) {
echo "data is empty";
} else {
echo $data;
}
}
?>
<form action="pro.php" method="post">
<label for="comment">Bio</label>
<input type="text" name="comment" id="comment">
<input type="submit" value="Submit">
</form>
</center>
</div>
pro.php
<?php
$conn = mysqli_connect("");
if($conn === false){
die("ERROR: Could not connect. "
. mysqli_connect_error());
}
$comment = $_REQUEST['comment'];
$sql = "INSERT INTO comment (comment)
VALUES ('$comment')";
if(mysqli_query($conn, $sql)){
echo "<h3>data stored in a database successfully."
. " Please browse your localhost php my admin"
. " to view the updated data</h3>";
echo $comment;
} else{
echo "ERROR: Hush! Sorry $sql. "
. mysqli_error($conn);
}
// Close connection
mysqli_close($conn);
?>
The info for the edpro.php file transfers to the pro.php file but is not inserting into DB. Goal is to have the DB info inserted display on pro.php. How do I fix my code if possible?
Thank ya