EDIT: Guys, thank you all for quick answers, I appreciate them. Have my upvotes y'all.
I'm doing a simple registration form. I want some fields (nickname and email) to be pre-filled when the user made an invalid input (an unallowed character in the password field for example).
I tried to achieve it like this:
<input type="text" name="nickname" placeholder="nickname" value=<?php if(isset($_POST["nickname"])) echo $_POST["nickname"]; ?> maxlength="30" required="required">
This only works when $_POST["nickname"]
is set, otherwise it uses maxlength="30"
as value.
Is there any way to make it use the placeholder when $_POST["nickname"]
is empty?
I'm quite new to PHP, I am sorry if my question sounds stupid. Also... apologies for my English.