Dymond
Dymond

Reputation: 2277

Two different values in one input form

I had created a login form that IF you enter the wrong username or password the value you entered in the username will be echoed back to the login form.

But now I want to add the value="LOGIN" to the form, when you haven't tried to login and if you enter the wrong user/pass it will change to the echoed value.

Hope you understand what i mean :)

This is my input code

<input type="text" name="username" id="username" value="<?php if (isset($_POST['username'])) echo  htmlentities($_POST['username']); ?>" />

Upvotes: 0

Views: 336

Answers (3)

j08691
j08691

Reputation: 207943

<input type="text" name="username" id="username" value="
<?php 
if (isset($_POST['username'])) echo htmlentities($_POST['username']); 
else echo "LOGIN";
?>" />

Upvotes: 5

romo
romo

Reputation: 1990

$val = isset($_POST['username']) ? htmlentitie($_POST['username']) : 'LOGIN';
<input type="text" value="<?=$val?>" />

Should do what you're looking for.

Upvotes: 0

Jim
Jim

Reputation: 1315

If I understand you correctly you just want the default value of the username textbox to be "LOGIN" and then when the user enters their information it changes? If that is correct, then just change the value to LOGIN. If I have misunderstood you, please try to clarify a little more what you want to accomplish.

Upvotes: 0

Related Questions