<pre>
$query = "select * from user WHERE username = '$username'";
$query_run = mysqli_query($con,$query);
</pre>
When I execute the program it show me this message. Undefined variable: con in
<pre>
$query = "select * from user WHERE username = '$username'";
$query_run = mysqli_query($con,$query);
</pre>
When I execute the program it show me this message. Undefined variable: con in
I do not know what your trying to query but based on your code snippet, you are using mysqli and you are making selection based on username. The code below will automatically connect you to database if database credential entered are okay and you can get results based on the queried username if the username info exist on your database
<html>
<head>
<title></title>
</head>
<body>
<?php
$dbhost = 'localhost:3306';
$dbuser = 'root';
$dbpass = '';
$dbname = 'your db';
$conn = mysqli_connect($dbhost, $dbuser, $dbpass,$dbname);
if(! $conn ) {
die('Could not connect: ' . mysqli_error());
}
echo 'Connected successfully<br>';
$sql = "select * from user WHERE username = '$username'";
$result = mysqli_query($conn, $sql);
if (mysqli_num_rows($result) > 0) {
while($row = mysqli_fetch_assoc($result)) {
echo "UserName: " . $row["username"]. "<br>";
}
} else {
echo "0 results";
}
mysqli_close($conn);
?>
</body>
</html>