How can a web application be designed to allow representatives to log in and access a customer management system based on their specific representative ID using PHP and MySQL?

To allow representatives to log in and access a customer management system based on their specific representative ID, you can create a login system where representatives enter their ID and password. Upon successful login, the system can verify the representative's ID against the database and grant access to the customer management system if the ID matches.

// Assuming representatives table in the database has columns: id, username, password

// Connect to MySQL database
$connection = mysqli_connect("localhost", "username", "password", "database_name");

// Check if form is submitted
if(isset($_POST['submit'])){
    $rep_id = $_POST['rep_id'];
    $password = $_POST['password'];
    
    // Query to check if representative ID and password match
    $query = "SELECT * FROM representatives WHERE id = '$rep_id' AND password = '$password'";
    $result = mysqli_query($connection, $query);
    
    if(mysqli_num_rows($result) == 1){
        // Representative is authenticated, redirect to customer management system
        header("Location: customer_management_system.php");
    } else {
        echo "Invalid representative ID or password";
    }
}

// HTML form for representative login
<form method="post" action="">
    <input type="text" name="rep_id" placeholder="Representative ID" required><br>
    <input type="password" name="password" placeholder="Password" required><br>
    <input type="submit" name="submit" value="Login">
</form>