Reputation: 63
Trying to do a simple validation. Tutorial shows this in order to do a validation:
<input type="text" name="userName" required tabindex=1><?php if (!is_null($user)) {echo 'value = "'. $user->getUserName() .'"';}?>
However on my file the "value=" displays on my page. So I tried this, putting value inside or outside PHP tags still yields no results.
First name:
<input type="text" name="firstName" <?php echo 'value = "'. $userData->getFirstName() .'"';?> required tabindex=1>
Upvotes: 0
Views: 57
Reputation:
currently you echo the value outside the close of input, so the browser displays it:
<input type="text" name="userName" required tabindex=1><?php if (!is_null($user)) {echo 'value = "'. $user->getUserName() .'"';}?>
change to
<input type="text" name="userName" required tabindex=1
<?php if (!is_null($user)) {echo 'value = "'. $user->getUserName() .'"';}?>
>
demo: http://codepad.viper-7.com/0Zf5EW
Upvotes: 2