Help with php validate function (form data in english only)

Discussion in 'PHP' started by FLOW-MATIC, Oct 13, 2010.

  1. #1
    Hello friends... i need help! lol...

    ok... so i am working on some form and in some place i am using this form data to be submitted to a script page that creates a new file and writing some data to the db ...

    one of the form fields i have the page name and i want it to be in English only or in a numeric format, or mix of both (page01 || page || 01).

    the problem is that the system is in Hebrew and some of the form fields should be submitted in Hebrew... so i need to make something for this specified filed to be in English or numeric charters only (like the ctype_alnum function... but for ENGLISH only)

    it is somthing like this... but need to be fixed for english only...
    $Filename             = $_REQUEST['FileName'];
    if ($Filename == (ctype_alnum($Filename))) {rest of the code} else echo "error";
    PHP:
    any help please?
     
    FLOW-MATIC, Oct 13, 2010 IP
  2. ChrisMac

    ChrisMac Peon

    Messages:
    28
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Hi, perhaps you can use preg_match instead:

    
    $Filename             = $_REQUEST['FileName'];
    if ($Filename == (preg_match('/^[a-z,0-9]+$/i',$Filename))) {rest of the code} else echo "error";
    
    PHP:
     
    ChrisMac, Oct 13, 2010 IP
  3. ActiveFrost

    ActiveFrost Notable Member

    Messages:
    2,072
    Likes Received:
    63
    Best Answers:
    3
    Trophy Points:
    245
    #3
    Agreed on this except .. I would not allow the use of commas.
     
    ActiveFrost, Oct 13, 2010 IP