johnpdmccall Posted December 10, 2006 Share Posted December 10, 2006 Hello all,I'm very new to PHP so please fogive my ignorance:I have a contact.html form which posts to contact.phpI think this code [code] return preg_replace($patterns, "", strtolower($value));[/code]from the code below, returns results in lower case? eg it converts "John McCall" to "john mccall"What do I replace that with to ensure that the case remains as the user writes it?This is part of a large bit of contact.php so if you need the rest please let me know:[code]//clean input in case of header injection attempts!function clean_input_4email($value, $check_all_patterns = true){ $patterns[0] = '/content-type:/'; $patterns[1] = '/to:/'; $patterns[2] = '/cc:/'; $patterns[3] = '/bcc:/'; if ($check_all_patterns) { $patterns[4] = '/\r/'; $patterns[5] = '/\n/'; $patterns[6] = '/%0a/'; $patterns[7] = '/%0d/'; } //NOTE: can use str_ireplace (instead of strtolower)as this is case insensitive but only available on PHP version 5.0. return preg_replace($patterns, "", strtolower($value));}$name = clean_input_4email($_POST["name"]);$email = clean_input_4email($_POST["email"]);$thesubject = clean_input_4email($_POST["thesubject"]);$phone = clean_input_4email($_POST["phone"]);$themessage = clean_input_4email($_POST["themessage"], false);[/code]Many thanks for any helpJohn Link to comment https://forums.phpfreaks.com/topic/30113-changing-case/ Share on other sites More sharing options...
Orio Posted December 10, 2006 Share Posted December 10, 2006 Instead of:[code]return preg_replace($patterns, "", strtolower($value));[/code]You should have:[code]return preg_replace($patterns, "", $value);[/code]:)Orio. Link to comment https://forums.phpfreaks.com/topic/30113-changing-case/#findComment-138466 Share on other sites More sharing options...
johnpdmccall Posted December 10, 2006 Author Share Posted December 10, 2006 Cheers Orio, it's easy when you know how ;DJohn Link to comment https://forums.phpfreaks.com/topic/30113-changing-case/#findComment-138475 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.