<?php
echo '<form action="';
echo $_SERVER['PHP_SELF'];
echo '" method="post"><input class="loginDropdownInput" type="text" name="user" value=';
if(isset($_COOKIE['rememeredusername'])=='true'){
echo $_COOKIE['rememeredusername'];
} else {
echo 'Username';
}
echo 'onclick="if(this.value == "Username") this.value="";" onblur="if(this.value.length == 0) this.value="" Username""; /></br></br><input class="loginDropdownInput" type="password" name="pass" value="Password" onclick="if(this.value == "Password"") this.value="";" onblur="if(this.value.length == 0) this.value="Password";"/>
?>
<span>
</br>
</br>
<span class="rememberMe">Remember me</span>
<input class="rememberMeBox" value="rememberme" name="rememberme" type="checkbox"/>
</span>
<a class="forgotPassword" href="../Accounts/forgot.php">Forgot your password?</a>
<?php
echo '<p class="loginErrorMessage">';
if ($userexists=='false'){
echo "Uh oh, try again...";
}
echo'</p><input class="submitDropdownInput" type="image" src="../Images/submitDropdownInput.png" alt="Login"/></form>';
?>
This is my code for a login portion of my site. However, input.loginDropdownInput keeps coming out with a value of “Usernameonclick=”if(this.value” instead of “Username”.
Where is my syntax error?
I don’t know what exactly are your needs, but I would seriously recommend you to stop mixing so much PHP and markup like you’re doing right now, it’s horrible to read and almost impossible to maintain.
Try doing something like:
PHP part:
HTML part:
Also you were using the onclick event, when you actually want it to be onfocus.
That’s what I could understand from your code, try to make your php reproduce something like this if this is what you need.
— Fixed some code errors.