Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Changin Lowercase letters into Uppercase
Old 02-17-2007, 06:33 PM Changin Lowercase letters into Uppercase
carterdea's Avatar
Ultra Talker

Posts: 353
Location: Arizona
Trades: 0
Hi, I need help with changing the 1st letter of names and such from lowercase to uppercase.

I am familiar with the "ucase" function, I just need a way to do something like this:

PHP Code:
ucase(firstletter($_POST('first_name'))) 
thanks
__________________

Please login or register to view this content. Registration is FREE
carterdea is offline
Reply With Quote
View Public Profile Visit carterdea's homepage!
 
 
Register now for full access!
Old 02-17-2007, 06:59 PM Re: Changin Lowercase letters into Uppercase
Ultra Talker

Posts: 256
Location: Auckland, New Zealand
Trades: 0
Hi carterdea,

What you're after is:

PHP Code:
ucfirst(strtolower($_POST['first_name'])); 
Just added alterations, as you'd probably want the rest to remain lower-case.

Cheers,

MC
__________________
#------------------------------signature---------------------------------------------------------------------------------#
Quote:
I am well recognised for what I don't do than what I do. Chores are just one of those things.

Last edited by mastercomputers; 02-17-2007 at 07:01 PM..
mastercomputers is offline
Reply With Quote
View Public Profile Visit mastercomputers's homepage!
 
Old 02-17-2007, 07:13 PM Re: Changin Lowercase letters into Uppercase
Novice Talker

Posts: 11
Name: Matthew Bagley
Trades: 0
Quote:
Originally Posted by carterdea View Post
Hi, I need help with changing the 1st letter of names and such from lowercase to uppercase.

I am familiar with the "ucase" function, I just need a way to do something like this:

PHP Code:
ucase(firstletter($_POST('first_name'))) 
thanks
The code you are seeking is
PHP Code:
ucfirst($_POST['first_name']); 
but remember you need to clear your code for javascript and other harmfull code first, also if you are inserting the information into the database then you will need to addslashes.

here is the function I use to format data
PHP Code:
    function encodedata($data$case 0$html 0){
        
## function to encode data into the database
        
$search = array('@<script[^>]*?>.*?</script>@si''@<style[^>]*?>.*?</style>@siU''@<![\s\S]*?--[ \t\n\r]*>@');
        
$data preg_replace($search''$data);
        if (
$html == 0)$data strip_tags($data);
        if (
$case !== 0)$data strtolower($data);
        
$data addslashes($data);
        
$data htmlentities($dataENT_QUOTES);
        return 
$data;
    } 
Hope that helps
__________________
Matthew Bagley
Paramiliar Design Studios

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE

Last edited by neomaximus2h; 02-17-2007 at 07:15 PM..
neomaximus2h is offline
Reply With Quote
View Public Profile Visit neomaximus2h's homepage!
 
Old 02-17-2007, 07:37 PM Re: Changin Lowercase letters into Uppercase
carterdea's Avatar
Ultra Talker

Posts: 353
Location: Arizona
Trades: 0
thanks both of you guys.

Quote:
Originally Posted by neomaximus2h View Post
but remember you need to clear your code for javascript and other harmfull code first, also if you are inserting the information into the database then you will need to addslashes.

here is the function I use to format data
PHP Code:
    function encodedata($data$case 0$html 0){
        
## function to encode data into the database
        
$search = array('@<script[^>]*?>.*?</script>@si''@<style[^>]*?>.*?</style>@siU''@<![\s\S]*?--[ \t\n\r]*>@');
        
$data preg_replace($search''$data);
        if (
$html == 0)$data strip_tags($data);
        if (
$case !== 0)$data strtolower($data);
        
$data addslashes($data);
        
$data htmlentities($dataENT_QUOTES);
        return 
$data;
    } 
Hope that helps
That 1st part certainly helps, but I'm sorry, why do I need to clear it of javascript and harmful code?
__________________

Please login or register to view this content. Registration is FREE
carterdea is offline
Reply With Quote
View Public Profile Visit carterdea's homepage!
 
Old 02-17-2007, 07:51 PM Re: Changin Lowercase letters into Uppercase
Ultra Talker

Posts: 256
Location: Auckland, New Zealand
Trades: 0
Well, basically what neo is trying to say is that if you don't validate your POSTed information, it could contain malicious code that you may not check for and remove.

It's a security thing that you should be conscious about. Just know that anything from a form, including your own information should be treated as untrusted, so make sure you just validate the content of your posted information and eliminate any risks.

Cheers,

MC
__________________
#------------------------------signature---------------------------------------------------------------------------------#
Quote:
I am well recognised for what I don't do than what I do. Chores are just one of those things.
mastercomputers is offline
Reply With Quote
View Public Profile Visit mastercomputers's homepage!
 
Old 02-17-2007, 08:52 PM Re: Changin Lowercase letters into Uppercase
carterdea's Avatar
Ultra Talker

Posts: 353
Location: Arizona
Trades: 0
great thanks. I will certainly add that to my code. Thank you greatly
__________________

Please login or register to view this content. Registration is FREE
carterdea is offline
Reply With Quote
View Public Profile Visit carterdea's homepage!
 
Reply     « Reply to Changin Lowercase letters into Uppercase
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.24335 seconds with 12 queries