Ok, I'm making a login and registration panel with jquery and php. In short, if there are errors with the registration it sets a few form errors, redirects back to the registration page, the javascript detects there are errors with the use of a php variable and forces the slider to show itself.
The working code: Above the doc type $errors = $form->num_errors;
and the whole $errors
routine works fine.
My problem is that I also have a verification that the form was submitted successfully. It uses
if(isset($_SESSION['regsuccess'])){
$success = 1;
} else {
$success = 0;
}
to set the $success
variable. The crazy thing here is that this doesn't work using the same routine as the $error
variable. I know the $success
conditional is working correctly as I have an it echoed out further down the page.
jQuery slide script:
$(document).ready(function() {
var num_errors = "<?php $errors; ?>";
var form_success = "<?php $success; ?>";
// Expand Panel
$("#open").click(function(){
$("div#panel").slideDown("slow");
});
// Collapse Panel
$("#close").click(function(){
$("div#panel").slideUp("slow");
});
// Switch buttons from "Log In | Register" to "Close Panel" on click
$("#toggle a").click(function () {
$("#toggle a").toggle();
});
//this part works
if(errors>0){
$("div#panel").slideDown();
$("#toggle a").toggle();
}
//this part doesn't
if(form_success>0){
$("div#panel").slideDown();
$("#toggle a").toggle();
}
});
The demo page is here http://demo.ivannovak.com/danlogin/index.php
Suggestions would be appreciated, thanks!