I am trying to execute some simple JQuery commands in an echo statement from PHP after the user submits a Log In form.
The user is able to Log In with the correct credentials, however if they enter incorrect ones it should show the invalid credentials paragraph.
Here is the code:
<?php
//PHP code for login in, working, not needed to show
echo 'Testing
<script>
$( ".wrong" ).show( "slow" );
</script>';
?>
<!DOCTYPE html>
<html>
<head>
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
</head>
<body class="login">
<form action="" method="post" class="login-form">
<p class="wrong" style="display: none;">Invalid Credentials</p>
<a class="link" href="#">Forgot your password?</a>
<button type="submit" class="login-btn" name="submitLogin">Log in</button>
</form>
</body>
NOTE: The Testing value from the echo displays, yet the JQuery does not execute.
It is not possible to put the PHP code after the HTML as it creates a session for my login form to work.
<!doctype>and<html>is invalid html, also you would be trying to execute jQuery calls before it has been included.session_start()should be at the top yes, but you don't have to echo your<script>at the top