Mam 3 pliki:
register.php:
session.php:
<?php function register($subuser, $subpass, $subemail){ /* Username error checking */ $field = \"user\"; //Use field name for username $form->setError($field, \"* Username not entered\"); } else{ /* Spruce up username, check length */ $form->setError($field, \"* Username below 5 characters\"); } $form->setError($field, \"* Username above 30 characters\"); } /* Check if username is not alphanumeric */ $form->setError($field, \"* Username not alphanumeric\"); } /* Check if username is reserved */ $form->setError($field, \"* Username reserved word\"); } /* Check if username is already in use */ else if($database->usernameTaken($subuser)){ $form->setError($field, \"* Username already in use\"); } /* Check if username is banned */ else if($database->usernameBanned($subuser)){ $form->setError($field, \"* Username banned\"); } } /* Password error checking */ $field = \"pass\"; //Use field name for password if(!$subpass){ $form->setError($field, \"* Password not entered\"); } else{ /* Spruce up password and check length*/ $form->setError($field, \"* Password too short\"); } /* Check if password is not alphanumeric */ $form->setError($field, \"* Password not alphanumeric\"); } /** * Note: I trimmed the password only after I checked the length * because if you fill the password field up with spaces * it looks like a lot more characters than 4, so it looks * kind of stupid to report \"password too short\". */ } /* Email error checking */ $field = \"email\"; //Use field name for email $form->setError($field, \"* Email not entered\"); } else{ /* Check if valid email address */ $regex = \"^[_+a-z0-9-]+(.[_+a-z0-9-]+)*\" .\"@[a-z0-9-]+(.[a-z0-9-]{1,})*\" .\".([a-z]{2,}){1}$\"; $form->setError($field, \"* Email invalid\"); } } $field = \"egold\"; if(!$subegold){ $form->setError($field, \"* egold not entered\"); } $field = \"mb\"; //Use field name for password if(!$submb){ $form->setError($field, \"* mb not entered\"); } /* Errors exist, have user correct them */ if($form->num_errors > 0){ return 1; //Errors with form } /* No errors, add the new account to the */ else{ if(EMAIL_WELCOME){ $mailer->sendWelcome($subuser,$subemail,$subpass); } return 0; //New user added succesfully }else{ return 2; //Registration attempt failed } } } ?>
process.php:
<?php function procRegister(){ /* Convert username to all lowercase (by option) */ if(ALL_LOWERCASE){ } /* Registration attempt */ $retval = $session->register($_POST['user'], $_POST['pass'], $_POST['email']); /* Registration Successful */ if($retval == 0){ $_SESSION['reguname'] = $_POST['user']; $_SESSION['regsuccess'] = true; } /* Error found with form */ else if($retval == 1){ $_SESSION['value_array'] = $_POST; $_SESSION['error_array'] = $form->getErrorArray(); } /* Registration attempt failed */ else if($retval == 2){ $_SESSION['reguname'] = $_POST['user']; $_SESSION['regsuccess'] = false; } } ?>
Oto moj błąd:
Nawet, gdy wpisze pole "mb" i "egold" pojawia sie, ze nie wpisalem tych danych....Jak to naprawić? Prosze też, żeby ktoś jak będzie poprawiał, odrazu zrobił, że trzeba albo pole mb wypełnić albo pole egold.
Odwdzięcze się :-)