Results 1 to 3 of 3

Thread: !ereg Problem

  1. #1
    Join Date
    Apr 2007
    Location
    Chelmsford, Essex
    Posts
    68

    !ereg Problem

    I have a register script that validates the fields and outputs errors if something is wrong, i want it to make sure that the field username can only be alphabetical and numeric characters so far i have

    PHP Code:
    elseif ( !ereg("[a-z A-Z 0-9]",$_POST[new_username]) )
    {
        
    $username_error "Username needs to be alphabetic and numeric characters<br>";
        include(
    "includes/register_form.php");
        
    HTMLFoot();
        exit();

    and when i submit it it forks for any other character before the actual text but if you put a dash or a plus or a non numeris/alphabetic character in then it lets you get away with it :-S does anyone know how i can stop EVERYTHING other than alphabetical upper case and lowercase and numerics??

    thanks

    Andy

  2. #2
    Join Date
    Mar 2002
    Location
    NJ
    Posts
    1,025
    Try it this way:

    elseif(ereg('[^A-Za-z0-9]', $_POST['new_username'])){


    Have a question about Maya or Web Dev? I'll try my best to give you a hand. PM for my email, or reach me on Skype or AIM as Johnska7.

    Did this post help you at all? Please feel free add to my reputation . Positive Feedback makes me happy!

    Tutorial Writer | Adjunct Professor of Advanced 3d Modeling and Animation

  3. #3
    Join Date
    Apr 2007
    Location
    Chelmsford, Essex
    Posts
    68
    Hey thanks that works a dream :-D

    Andy

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •