Reputation: 2277
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
Reputation: 207943
<input type="text" name="username" id="username" value="
<?php
if (isset($_POST['username'])) echo htmlentities($_POST['username']);
else echo "LOGIN";
?>" />
Upvotes: 5
Reputation: 1990
$val = isset($_POST['username']) ? htmlentitie($_POST['username']) : 'LOGIN';
<input type="text" value="<?=$val?>" />
Should do what you're looking for.
Upvotes: 0
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