What I want is the login to get the data from the database, and display the welcome page. \im not sure why it is not working, I had PHP 8 and I did my code I always get a blank page, be it retrieving data from a database or adding data. all I get is a blank page with no action. This is my HTML code:
**<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Movie Site</title>
<link rel="stylesheet" href="style.css" type="text/css" />
</head>
<body>
<div class="login">
<h1>MY MOVIE SITE</h1>
<h1>Login</h1>
<form action="insert.php" method="post">
<input type="text" name="u" placeholder="username" required="required" />
<input type="password" name="p" placeholder="password" required="required" />
<button type="submit" class="btn btn-primary btn-block btn-large">Let me in.</button>
</form>
</div>
</body>
</html>**
Then my PHP is:
**<?php
$username = $_POST['username'];
$password = $_POST['password'];
$username = stripcslashes($username);
$password = stripcslashes($password);
$username = mysql_real_escape_string($username);
$password = mysql_real_escape_string($password);
mysql_connect("localhost", "root", "");
mysql_select_db("login");
$result = mysql_query("select * from user where username = '$username' and password = '$password'")
or die ("failed to query database".mysql_error());
$row = mysql_fetch_array($result);
if ($row['username'] == $username && $row['password'] == $password){
echo "login success!! WELCOME ".$row[username];
}
else{
echo 'Failed to log in';
}
?>**
Thanks in advance. I have tried and checked where I am wrong and googled, I don't seem to understand what I am missing out on. PHP version I'm using is 7.2.34 I moved the version lower from 8 since I thought it could be version errors and wrong syntax with the new version. But doesn't seem to be the case.