Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Data Validation

RenzozukenRenzozuken Posts: 7Member
i need php script for error reporting and correction of data ,taken from the form from user

i want to make sure that entered

#data must be char
#and must not be number

so plz..........
help a programmer..

Comments

  • mac_doggiemac_doggie Posts: 488Member
    [b][red]This message was edited by mac_doggie at 2005-2-14 4:22:8[/red][/b][hr]
    : i need php script for error reporting and correction of data ,taken from the form from user
    :
    : i want to make sure that entered
    :
    : #data must be char
    : #and must not be number
    :
    : so plz..........
    : help a programmer..
    :
    :
    You can read the entered values of your form with the $_GET and $_POST arrays. A chack can be build with stringfunctions and/or regular expressions... (http://www.php.net/manual/nl/ref.strings.php)

    you can also use functions: is_integer is_string is_numeric etc.
    A char doesn't exist in PHP that would automaticly be a string, so you can check if it's a string and if the length is 1:
    [code]
    if(is_string($_POST["myVar"]) && strlen($_POST["myVar"])==1) {
    echo "ok...";
    }else {
    echo "value is not a char...";
    }

    // or

    if(!is_numeric($_POST["myVar2"])) {
    echo "ok";
    }else {
    echo "your value is numeric but shouldn't be....";
    }
    [/code]


    ;-)
    -mac-
    mailto:mac_doggie@hotmail.com
    the Netherlands...




Sign In or Register to comment.