Jump to content

Changing Case


johnpdmccall

Recommended Posts

Hello all,

I'm very new to PHP so please fogive my ignorance:

I have a contact.html form which posts to contact.php

I 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 help
John


Link to comment
https://forums.phpfreaks.com/topic/30113-changing-case/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.