Welcome Guest, Not a member yet? Register   Sign In
How to use ucwords on form variables ?
#1

[eluser]dhaulagiri[/eluser]
Hi friends, I have a field name "first_name" in my form. When posted to database I want it to be capitalize, please help me how do i do that ?

This is a html form
Code:
<input type="text" style="text-transform: capitalize;" name="last_name" id="last_name" class="input-text" value="<?php echo ucwords($_POST['last_name']);?>"/>

This is a controller
Code:
$data['last_name']= ucwords($_POST['last_name']);

This didn't work. Pls help
#2

[eluser]cchi[/eluser]
Are you trying to pass the posted value back to your form?? Cause if you are try to use the set_value() function of codeigniter.

http://ellislab.com/codeigniter/user-gui...elper.html

Code:
<input type="text" name="quantity" value="<?php echo set_value('quantity', '0'); ?>" size="50" />


$data['last_name']= ucwords($_POST['last_name']); //when you do this you're passing the value back to your form' set the post value to a variable in order to submit it to a query.

>>$last_name = ucwords($_POST['last_name']);
#3

[eluser]Thorpe Obazee[/eluser]
Use it as a rule in the form validation:

Code:
$this->form_validation->set_rules('username', 'Username', 'ucwords|trim|required|min_length[5]|max_length[12]|xss_clean');

Quote:Note: You can also use any native PHP functions that permit one parameter, like trim, htmlspecialchars, urldecode, etc.




Theme © iAndrew 2016 - Forum software by © MyBB