djfox Posted January 1, 2008 Share Posted January 1, 2008 I have this section of a form made: <b>Gender:</b> <br><select name="gender" style="border: 0px; background-color:#000000; color: #B6ABCE;"> <option value="b">Both <option value="f">Female <option value="m">Male </select> Here`s the php section that the results of all of the fields in the form are sent to: $add="INSERT INTO clothing ( name, desc2, shortname, store, files, layers, gender, posespec, type, cost, spec, date ) VALUES ( '$title', '$des', '$short', '$region', '$filenames', '$lay', '$gender', '$pose', '$type', '$price','$spe', '$entry_date' )"; $res = mysql_query($add) or die(mysql_error()); When the field entry for gender is supposed to be is "b". But when the form is filled out and sent, the gender entry "b" is somehow changed to "B", which causes complications for several other pages. The "gender" field in the database table was set to char type and thinking that was why, I tried changing it to varchar. But the mysql doesn`t want to change it to varchar. What should I do to keep the letter lowercase? Quote Link to comment https://forums.phpfreaks.com/topic/83916-solved-php-changing-my-form-input/ Share on other sites More sharing options...
sKunKbad Posted January 1, 2008 Share Posted January 1, 2008 you could try the php function strtolower() Quote Link to comment https://forums.phpfreaks.com/topic/83916-solved-php-changing-my-form-input/#findComment-427064 Share on other sites More sharing options...
djfox Posted January 1, 2008 Author Share Posted January 1, 2008 Odd, it inputted "fe" instead of "b". Quote Link to comment https://forums.phpfreaks.com/topic/83916-solved-php-changing-my-form-input/#findComment-427069 Share on other sites More sharing options...
p2grace Posted January 1, 2008 Share Posted January 1, 2008 What do you mean when you say the database doesn't want to change it to varchar? What does it do? Quote Link to comment https://forums.phpfreaks.com/topic/83916-solved-php-changing-my-form-input/#findComment-427071 Share on other sites More sharing options...
djfox Posted January 1, 2008 Author Share Posted January 1, 2008 What do you mean when you say the database doesn't want to change it to varchar? What does it do? It keeps changing it back to char. It updates the lengths but it won`t update the type. Quote Link to comment https://forums.phpfreaks.com/topic/83916-solved-php-changing-my-form-input/#findComment-427072 Share on other sites More sharing options...
p2grace Posted January 1, 2008 Share Posted January 1, 2008 Try adding another field that has a varchar type. Then write a quick sql statement that will copy whatever is in the char field to the varchar field. Then delete the char field, and rename the varchar field to what the name the char field was. Quote Link to comment https://forums.phpfreaks.com/topic/83916-solved-php-changing-my-form-input/#findComment-427074 Share on other sites More sharing options...
djfox Posted January 1, 2008 Author Share Posted January 1, 2008 Now I`m worried. I set the new field gend to type varchar and the table immediately changed it to char and won`t let me change that type either. My mistake, I did not realize that varchar needs a larger number than 2 for it`s lengths. Quote Link to comment https://forums.phpfreaks.com/topic/83916-solved-php-changing-my-form-input/#findComment-427076 Share on other sites More sharing options...
djfox Posted January 1, 2008 Author Share Posted January 1, 2008 Ok, I got gender set to varchar (hoping that it would leave the input alone and not capitalize anything). Now the form sends "Both" instead of "b". (First post shows that the value to be sent should be just "b".) Strange I`ve never had such a problem with forms before. =P Quote Link to comment https://forums.phpfreaks.com/topic/83916-solved-php-changing-my-form-input/#findComment-427078 Share on other sites More sharing options...
p2grace Posted January 1, 2008 Share Posted January 1, 2008 Try closing your option tags <br><select name="gender" style="border: 0px; background-color:#000000; color: #B6ABCE;"> <option value="b">Both</option> <option value="f">Female</option> <option value="m">Male</option> </select> Quote Link to comment https://forums.phpfreaks.com/topic/83916-solved-php-changing-my-form-input/#findComment-427083 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.