In register.php file included javascript code for username (email, passw, etc.) validation.
For example, Javascript contains such code var url = "_password_confirmation_validator.php";
_password_confirmation_validator.php gets values from input form (register.php) and validates input.
Anyone who view source of register.php can see that on server exists file _password_confirmation_validator.php
When I navigate directly to _password_confirmation_validator.php I can see message like Password is empty.
If in _password_confirmation_validator.php I place header redirect (to redirect if someone directly navigate to the file, then ajax does not work).
Also ajax does not work if in _password_confirmation_validator.php I place condition like
if ($_POST['register'] ){
Form input field is like input onkeyup= (so onkeyup ajax starts to validate).
Questions are
1) How to write some condition for _password_confirmation_validator.php to show nothing if someone navigates directly?
2) Is there any security problems if someone can see file names in view source? If yes, what would be solution?