I am stuck in php

project
php

#1

Please i am stuck trying to create a chat room for some users. This messeage came up.!


#2

Can you copy the content from the entire file to the forum?


#3

i am having trouble uploading the file.

<?php

session_start();


?>
<!DOCTYPE html>
<html>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<head>
<title>chatroom</title>

<style>

#main{
	background-image: url(images/1.jpg);
	color:white;
	font-family: verdana;
	font-weight: 0.8em;
	border-radius: 10px;
	padding: 8px;
	height:900px;
	width: 50%;
}
#go{
	padding:5px;
	background:transparent;
	color:white;
	font-family: verdana;
	font-weight: 0.8em;
	border-radius: 8px;
	width: 100%;
	cursor: pointer;

}
#gone{
padding:5px;
	background:transparent;
	color:white;
	font-family: verdana;
	font-weight: 0.8em;
	border-radius: 8px;
	width: 100%;
	cursor: pointer;
	margin-top: 15%;

}

.form-control{
	width:100%;
	border-radius: 5px;
	height:100px;
	background: transparent;
	color:white;
	font-family: verdana;
	font-weight: 0.8em;
}
#zero{
	padding:8px;
	background-color: lightgreen;
	display: inline-block;
	border-radius: 100%;
}
.output{
	background:transparent;
    box-shadow: 0px 2px 2px #000;
    height: 520px;
    margin-bottom: 20px;
    overflow: scroll;

}
</style>
</head>
<body>

<div id="main">
<h2><code><?php echo $_SESSION['name']?></code> <code>Is Online</code> <div id=zero></div></h2>
<hr>

<div class="output">

<?php $sql="SELECT * FROM posts";
$result=$conn->query($sql);

if($result->num_rows > 0){
	//output data for each row
	while($row = $result->fetch_assoc()){

		echo "". $row["name"]. " " .":: " . $row["msg"]." --" .$row["date"]. "<br>";
		echo "<br>";
	}

}else{
	echo "0 results";
}
$conn->close();
?>


</div>
<form action="send.php" method="post">
	<textarea class="form-control" name="msg" placeholder="Type Message To Send...."></textarea><br>
	<input id="go" type="submit" value="Send Message">
	
	
	
</form>

<hr>


<form action="logout.php">
		<input id="gone" type="submit" value="Logout">
		

	</form>

</div>

</body>
</html>

#4

where do you make the connection to the database? You need to connect to a database to execute a query.


#5

Check this post (made by me): Connect to database basis.


#6

Am new here someone help me