How can PHP be used to generate and display a password with an inputted name?

To generate and display a password with an inputted name in PHP, you can concatenate the inputted name with a randomly generated string to create a unique password. You can then display this password to the user.

<?php
if(isset($_POST['name'])) {
    $name = $_POST['name'];
    $password = $name . rand(1000, 9999); // Concatenate name with a random number
    echo "Generated password for $name: $password";
}
?>

<form method="post">
    <label for="name">Enter your name:</label>
    <input type="text" name="name" id="name">
    <button type="submit">Generate Password</button>
</form>