Results 1 to 2 of 2

Thread: Check strings from text field

  1. #1
    Join Date
    May 2012
    Location
    Wales UK
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Check strings from text field

    I made a script to submit the information to mysql database... but now i need to check the strings that were submitted and every example i find does not seem to help atall so i come up with something simple like this

    PHP Code:
    if (!strlen(trim($_REQUEST['usersname']))){
            die(
    'Please go back and enter out the required name!');
        } 
        elseif (!
    strlen(trim($_POST['comment1']))){
                    die(
    'Please go back and enter out the required comment!');
        }else{

    ///process all my mysql data past this line

    username and comment1 are both fields that are on the index page and this code is processed on the submit button

    as you can see im trying to make it stop if the username is not there then check to see if the comment is there and if they are both there carry on.

    It will stop but it always stops even if the data is there. Kind of new to this code need some help desperatly!

    Thanks in advance

  2. #2
    Join Date
    Jul 2010
    Location
    Minnesota
    Posts
    256
    Thanks
    1
    Thanked 21 Times in 21 Posts

    Default

    Use the empty() instead
    PHP Code:
    $username trim($_REQUEST['usersname']);
    if (empty(
    $username)) 

Bookmarks

Posting Permissions

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