I would like my server side PHP validation on a log in page to trigger an error in the client side jquery validation plug in validation. With non log in forms - structured to use a remote file as an action I just echo back a msg then trigger the client side validation error/success msg based on that returned value. I received some suggestions here before, but they did not work - some syntax errors (or my ignorance) here's some pseudocode:
<?php
$username = "foo";
$password = "bar";
if ($_POST['username'] != $username || $_POST['password'] != $password) {
#would like to trigger the #errormsg here
?>
<!DOCTYPE>
<html>
<head></head>
<body>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" >
</body>
</html>
<?php
}
else {
?>
<!DOCTYPE>
<html>
<head></head>
<body>Logged in user sees this content</body>
</html>
<?php
}
?>
In my validation script the following:
//beginning
success: function(data) {
if (data=="Error") {
$("#Error").html('ERROR MSG HERE').show();
} else {
$("#Success").html('SUCCESS MSG HERE').show();
}
//rules, msgs etc
Currently if a user enters the wrong un/pwd it just resets the form, I'd like to tell them the info they entered was wrong. I know PHP can output JS - trying to just do something like in the PHP - but wherever I put that I get some syntax erros due to how the sections are broke up btwn the "} else {:
<?php
$username = "foo";
$password = "bar";
if ($_POST['username'] != $username || $_POST['password'] != $password) {
<script>
$(document).ready(function() {
$("#Error").html('ERROR MSG HERE').show();
});
</script>
?>
thanks!