Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 2 of 2

Thread: string checking

  1. #1
    Senior Member
    Join Date
    May 2003
    Location
    UK
    Posts
    2,354
    Member #
    1326
    Hey, I have a column for the username in a table, and want to know if it is possible to check if a posted value has a "." in it?

    PHP Code:
     (some pseudocode)
    $user_name $_POST['user_name'];
    if(
    $user_name contains ".") {
      echo 
    "no dots please";} 
    Also, to check the MIME type of a file to be uploaded, I use
    PHP Code:
    $_FILES['userfile']['type'
    but read somewhere online that the MIME type can be spoofed.

    Should I trust my users or is there a way to check the extension of $_FILES['userfile']['type'] for values like .jpg,.png (allowed) rather than .exe,.com

    Thanks a lot in advance

  2.  

  3. #2
    Senior Member
    Join Date
    Aug 2003
    Posts
    444
    Member #
    2801
    To check whether a dot exists in a string, use the stristr() function: http://uk.php.net/manual/en/function.stristr.php

    To check the file extension, use pathinfo:
    http://uk.php.net/manual/en/function.pathinfo.php
    Be sure to read the user-posted comments for pathinfo.
    eKstreme
    eKstreme.com - Free website tools!
    fontfox - free fonts Hand-picked quality fonts.


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 01:35 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com