I have a visiting panel on my site with a registration form. That is, when you click on the "register" button, the page is not updated, just the panel leaves and the alert pops up:

"e-mail sent a letter ...".

Here is my code:

  $sticker.click(function() { if ($panel.hasClass('visible')) { <?php if($_GET["email"]==""||$_GET["pass"]==""){ ?> alert("Введите e-mail и пароль!"); <?php } else {?> hidePanel(); <?php } ?> } else { showPanel(); } }); 

And so, whatever I wrote in the "email" and "pass" , I always pop up:

"Enter your e-mail and password!".

  • Whatever I wrote in "email" and "pass" - where exactly do you write in "email" and "pass"? - Grundy
  • @Grundy, in <input type="text" name="email"> and <input type="password" name="pass"> respectively. Which are inside the form with action="get" . And the form already in the div with the panel itself. - i am so lame

1 answer 1

because at the time of loading the page you have the parameters $ _GET ["email"] and $ _GET ["pass"] do not exist in your check: this piece of code

 <?php if($_GET["email"]==""||$_GET["pass"]==""){ ?> 

as it says and works out .. if you want to check the entered data, then you need to catch the data entered in the form fields js, it is done like this in jquery:

 email=$('id или класс поля email формы ').val(); pass=$('id или класс поля pass формы').val(); 

and then check

  if(email==''||pass==''){ alert("Введите e-mail и пароль!"); }else{ hidePanel();// ваша функция закрытия видимо } 
  • But I specifically used php to later enter the data into the mysql database, how can I do this on jquery? - i am so lame pm
  • @iamsolame, and you know the difference between php and javascript (jquery)? - Grundy
  • @Grundy, php works with the server, and JavaScript - with a browser? - i am so lame
  • I think teaching you the basics of web programming in the comments is not a resource task - Broouzer King
  • @BroouzerKing, I don’t need it, I just want to solve my problem. And, as I understand it, what I am trying to do is nonsense? The only thing that will help me is the ajax? - i am so lame