I'm working on creating a chat application with a single interface. I've encountered an issue where the content in the middle div "messages" keeps bouncing, including the scroll bar. How can I resolve this problem?
Additionally, I'm unable to keep the scroll bar at the top position. Any tips on fixing this as well?
Below is my complete code:
Main code :
<?php
include 'db.php';
if(isset($_POST['send']))
{
header("Location:chat.php");
$chat=$_POST['chat'];
$sql="INSERT INTO chat_info(chat) values('$chat')";
$query=mysqli_query($conn,$sql);
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Chat Application</title>
<style>
/* Your CSS styles here */
</style>
</head>
<body>
<!-- Your HTML content goes here -->
</body>
Additional PHP function for connecting to the database :
<?php
$host="localhost";
$user="root";
$db="chat";
$conn=mysqli_connect($host,$user,"",$db);
if(! function_exists('formatDate'))
{
function formatDate($date){
return date('g:i a',strtotime($date));
}
}
?>