Closed. This question needs to be more
focused. It is not currently accepting answers.
My Answer:
To display the full name instead of the username in a PHP login form, you would need to have a database table that stores the user's full name along with their username and password. When the user logs in successfully, you can retrieve their full name from the database based on their username and display it on the page.
Here is a basic example of how you can achieve this:
1. Create a database table (e.g., users) with columns for username, password, and full name.
2. When the user logs in, query the database to check if the username and password match. If they do, retrieve the full name associated with that username.
3. Display the full name on the page after a successful login.
Here is a simple example code snippet:
php
// Check if the form is submitted
if ($_SERVER["REQUEST_METHOD"] == "POST") {
// Check if the username and password are correct (you should validate and sanitize user input)
$username = $_POST["username"];
$password = $_POST["password"];
// Query the database to check if the username and password match
// Assuming you have a database connection $conn
$query = "SELECT full_name FROM users WHERE username = '$username' AND password = '$password'";
$result = mysqli_query($conn, $query);
if (mysqli_num_rows($result) == 1) {
// User logged in successfully, retrieve the full name
$row = mysqli_fetch_assoc($result);
$full_name = $row["full_name"];
// Display the full name
echo "Welcome, $full_name!";
} else {
echo "Invalid username or password";
}
}
?>
Please note that this is a basic example and you should always use secure practices when handling user authentication and database queries.