Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Sep 2007
    Posts
    137
    Thanks
    1
    Thanked 0 Times in 0 Posts

    form validation using php

    hi

    i need to validate a field in a form where a user enters their lodgement number as part of a registration form. this lodgement number can have letters, numbers, spaces and special characters. i do not know exactly what those special characters are, so do i have to define the type of special characters and validate accordingly.

    presently my php code for validating the lodgement number is
    PHP Code:
    $lodgementtf  $_POST["lodgementtf"];   

    if(
    $lodgementtf == "" || !preg_match("/^[a-zA-Z0-9_ <]+$/"$lodgementtf) ) 
    {
    echo 
    "display error message":

    i also have another way of validating
    PHP Code:
    if($lodgementnumber == "" || !preg_match("/^[a-zA-Z0-9_ !-@£$%^&*()]+$/"$lodgementnumber) ) 
    does this mean that the special characters can only be = a space AND _!-@&#163;$%^&*() and no other special characters.

    please advice.

    thanks.
    Last edited by Inigoesdr; 05-14-2008 at 09:33 PM.

  • #2
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,647
    Thanks
    2
    Thanked 406 Times in 398 Posts
    Please remember to read the stickies for this forum. In particular the one about using [php][/php] tags when posting code.


  •  

    Posting Permissions

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