Jump to content


Photo

case sensitivity


  • Please log in to reply
3 replies to this topic

#1 Tandem

Tandem
  • Members
  • PipPipPip
  • Advanced Member
  • 251 posts

Posted 30 August 2006 - 12:36 AM

Hi, on my site i want to try and stop users from inputting a certain phrase i.e their own username, into a particualr form input. However users can get around what i have put in place by inputting their username in a different case or combination of cases. What would be the best way to detect whether they have input the particular word, in any case?

#2 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 30 August 2006 - 12:40 AM

eregi
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#3 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 30 August 2006 - 12:46 AM

.. or convert their input to all the same case using either strtolower() or strtoupper()
Legend has it that reading the manual never killed anyone.
My site

#4 Jenk

Jenk
  • Members
  • PipPipPip
  • Advanced Member
  • 778 posts

Posted 30 August 2006 - 09:07 AM

eregi is deprecated, use preg_* functions instead.

Otherwise use stri* functions for direct matches:
<?php

$string = 'FoO';

if (stripos($string, 'foo') !== false) {
    //case insentivie match for foo found
}

if (preg_match('/foo/i', $string)) {
    //case insensitive match for foo found
}

?>
[/code]




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users