Hei, jeg lurte på om noen kunne hjelpe meg med bokstav-sjekk før registrering, altså det jeg vil at funksjonen sjekker om navnet ikke innholder spesielle tegn, kun følgende tegn: _ - ( ) [ ] , . 0-9 og a-z, hvordan får jeg dette til dersom jeg har koder under:
Takk for svar!
Kode
function do_Register(){ global $db, $prefix, $username, $password, $password2, $email, $fullname, $sex, $usercolour, $user_taken_err, $email_taken_err; global $site_name, $site_email, $site_url; //this function will check fields incase of javascript not working. if((!$username) || (!$password) || (!$password2) || (!$email)){ if(trim(empty($username))){ } if(empty($password)){ } if(empty($password2)){ } if(trim(empty($email))){ } //print the error message and load the form. include("header.php"); register_form(); echo "<table width=\"386\" border=\"0\" cellpadding=\"2\" cellspacing=\"2\"> <tr align=\"center\"> <td class=\"error\">"._ERROR_PLEASE_FILL_FIELDS."</td> </tr> </table>"; include("footer.php"); exit(); } //this code will check if the 2 passwords are match or not. if($password != $password2){ //print the error message and load the form. include("header.php"); register_form(); echo "<table width=\"386\" border=\"0\" cellpadding=\"2\" cellspacing=\"2\" > <tr align=\"center\"> <td class=\"error\">"._ERROR_PASSWORD_DOESNT_MATCH."</td> </tr> </table>"; include("footer.php"); exit(); } //this code will check if the email is correct or not if(!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)){ //print the error message and load the form. include("header.php"); register_form(); echo "<table width=\"386\" border=\"0\" cellpadding=\"2\" cellspacing=\"2\" > <tr align=\"center\"> <td class=\"error\">"._ERROR_INVALID_EMAIL."</td> </tr> </table>"; include("footer.php"); exit(); }