如何在用户输入结尾添加文本?

I have been given some spaghetti code for a login page to fix.

We've got two input fields ID and Password.

Here's what I've been asked. So in terms of a user inputting their ID, I want to add '@email.com' onto the end.

Im assume placeholder="@email.com" would work if i could align it to the right, but I also need to it to be added into the POST method. So if the user entered 'ID123' it would post 'ID123@email.com'

Here is the form:

<form action="command.php" formmethod="post">
       <div class="ID">User ID:<br><input name="ID" type="text"><br></div>
        <div class="Pass"> Password:<br><input name="pwd" type="password"></div>
        <input id="submit" type="submit" value="Sign In">

Can anyone help? Is it even possible?

</div>

Placeholder in the input type in HTML will just give a hint in a textbox and it will not be added into the input of the user. What you need to do is catch the input type in the command.php you created and add it.

for example, in the command.php

$ID = $_POST['ID'].'@gmail.com'

When you submit the form, your POST data will contain:

$_POST['ID'] = 'test_id';   // Sample Data
$_POST['pwd'] = 'test_pwd'; // Sample Data

So, if you want to add @email.com at the end of the ID, you could simply concatenate the field:

$_POST['ID'] .= '@email.com';

Note: This is a simple solution and doesn't specify SQL injection/vulnerability prevention.

I think you want something like if anyone give ID123@email.com as input it will not change but if only give ID123 then it will be ID123@email.com,then :-

$userId=$_POST['ID'];
if(!filter_var($userId, FILTER_VALIDATE_EMAIL)) {
$userId=$userId.'@email.com';     
}
echo $userId;