Napisałem sobie drobny skrypt walidacji formularza. System oczywiście działa, wszystko ładnie, tylko mam pytanie. Robię to w ten sposób:
<?php // Check if the passwords match if ($_POST['password'] != $_POST['confirmpass']) { $reg_error = 'Your passwords do not match'; include 'templates/head.tpl'; include 'templates/top.tpl'; include 'templates/register.tpl'; include 'templates/left.tpl'; include 'templates/footer.tpl'; exit; } if (!check_password_and_username($password)) { $reg_error = 'Your passwords and login could not be the same'; include 'templates/head.tpl'; include 'templates/top.tpl'; include 'templates/register.tpl'; include 'templates/left.tpl'; include 'templates/footer.tpl'; exit; } if (!validSecurity($security)) { // Reshow the form with an error $reg_error = 'You provided wrong security answer'; include 'templates/head.tpl'; include 'templates/top.tpl'; include 'templates/register.tpl'; include 'templates/left.tpl'; include 'templates/footer.tpl'; exit; } $username = $_POST['username']; if (!check_username($username)) { // Reshow the form with an error $reg_error = 'Requested username is aldready in use'; include 'templates/head.tpl'; include 'templates/top.tpl'; include 'templates/register.tpl'; include 'templates/left.tpl'; include 'templates/footer.tpl'; exit; } $email = $_POST['email']; if (!check_email($email)) { // Reshow the form with an error $reg_error = 'Requested e-mail address is aldready in use'; include 'templates/head.tpl'; include 'templates/top.tpl'; include 'templates/register.tpl'; include 'templates/left.tpl'; include 'templates/footer.tpl'; exit; } ?>
To tylko fragment kodu. Teraz kolej na pytanie: Czy ten kod jest napisany poprawnie?

Teraz pytanie poboczne. Czy muszę w każdym pliku serwisu include'ować plik init.php /łączenie z bazą/ czy tylko w tych, które tego wymagają. Register_globals mam wyłączone. Całe logowania odbywa się na sesjach, więc na chłopski rozum biorąc, nie potrzeba, ale chciałbym poznać opinie specjalistów.
Pozdrawiam
A.