NoDoze Posted September 10, 2008 Share Posted September 10, 2008 I have a PHP form, which when entered into the mysql database, I only want to be lowercase characters only, possible? Quote Link to comment https://forums.phpfreaks.com/topic/123655-solved-lowercase-only/ Share on other sites More sharing options...
NoDoze Posted September 10, 2008 Author Share Posted September 10, 2008 Hmmmm....ok.... I think I'm closer, but still don't understand.... This is from my code: $user_id = $_POST['user_id']; How would I apply this to it? $string = "This-Is An! Example234"; $string = preg_replace('/[^0-9a-z]*/','',strtolower($string)); Would it be...? $user_id = preg_replace('/[^a-z]*/','',strtolower($_POST['user_id'])); Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/123655-solved-lowercase-only/#findComment-638547 Share on other sites More sharing options...
Maq Posted September 10, 2008 Share Posted September 10, 2008 $user_id = $_POST['user_id']; $user_id = strtolower($user_id); Quote Link to comment https://forums.phpfreaks.com/topic/123655-solved-lowercase-only/#findComment-638552 Share on other sites More sharing options...
NoDoze Posted September 10, 2008 Author Share Posted September 10, 2008 This is used in a form, so wouldn't I still need to use 'POST' to define the variable? Or would that do both tasks? Quote Link to comment https://forums.phpfreaks.com/topic/123655-solved-lowercase-only/#findComment-638555 Share on other sites More sharing options...
Maq Posted September 10, 2008 Share Posted September 10, 2008 What do you mean? My code does use $_POST. This code is assuming the user hits 'submit' and the form is submitted to the processing page/script. With $_POST all you do is call the name of the input field. So if you have: Then you would get the submitted information by calling... $user_id = $_POST['NoDoze']; Is this what you're asking or helpful? Quote Link to comment https://forums.phpfreaks.com/topic/123655-solved-lowercase-only/#findComment-638567 Share on other sites More sharing options...
NoDoze Posted September 10, 2008 Author Share Posted September 10, 2008 Oh! Woops.... You're talking about putting BOTH lines....Ahhhh! I was thinking you meant replace the first with the second... Sorry for the misunderstanding! heh. Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/123655-solved-lowercase-only/#findComment-638577 Share on other sites More sharing options...
Maq Posted September 10, 2008 Share Posted September 10, 2008 No worries. I haven't tested that code but I'm pretty sure it will work. Quote Link to comment https://forums.phpfreaks.com/topic/123655-solved-lowercase-only/#findComment-638580 Share on other sites More sharing options...
NoDoze Posted September 10, 2008 Author Share Posted September 10, 2008 Worked perfectly! But now I realize I have another problem... the same variable is creating the user folder too! So... mkdir ("/home/dir/dir/ftp/{$_POST['user_id']}") is creating the directory with the mixed caps. how would I alter this to take lowercase only? mkdir ("/home/dir/dir/ftp/$user_id") So that it would take the defined variable from above instead in lowercase? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/123655-solved-lowercase-only/#findComment-638590 Share on other sites More sharing options...
Maq Posted September 10, 2008 Share Posted September 10, 2008 You want the directory path to use the lowercase string? mkdir ("/home/dir/dir/ftp/".$user_id."") Quote Link to comment https://forums.phpfreaks.com/topic/123655-solved-lowercase-only/#findComment-638594 Share on other sites More sharing options...
NoDoze Posted September 10, 2008 Author Share Posted September 10, 2008 Yup! I'll give that a try... Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/123655-solved-lowercase-only/#findComment-638599 Share on other sites More sharing options...
NoDoze Posted September 10, 2008 Author Share Posted September 10, 2008 Worked like a charm! Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/123655-solved-lowercase-only/#findComment-638642 Share on other sites More sharing options...
Maq Posted September 11, 2008 Share Posted September 11, 2008 No problem, glad I could help. Quote Link to comment https://forums.phpfreaks.com/topic/123655-solved-lowercase-only/#findComment-638802 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.