Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML Form Values PHP and Spaces

Tags:

html

forms

php

I am working on various projects for my organization that were started by another developer. A good portion of this work involves form processing with PHP.

I was rather surprised to see that for many of the form values, the previous developer used spaces (for example <input type="radio" value="DO NOT ENROLL" name="proceed" /> ). I think I know why he did it - he sends it as it email and makes it easy to display the values in a human readable format without additional processing, but, as someone who is used to 'typical' programming naming conventions (no spaces, camel case, pascal case, and so on), this does make me a little uneasy. Whenever I have processed HTML forms and assigned values, I believe I always tried to following "typical" variable naming conventions, but this could have habit rather than a necessary practice.

Now, I am not saying he is wrong, but I tried to do a little research on the topic and have not reached a definite conclusion. So my question is this - is there anything wrong with including spaces in values assigned to HTML form input elements - particularly when it will be sent over email? If so, what complications may result, and is there a way to properly process them, or would you recommend keeping the actual form values simple (for example, <input type="radio" value="decline" name="proceed" /> and THEN processing them to make them more readable after the form is submitted.

Thanks for any input!

like image 418
KellyM Avatar asked Apr 01 '26 20:04

KellyM


2 Answers

There is nothing bad, except the only real restriction on what characters can appear in form control names is when a form is submitted with GET

"The "get" method restricts form data set values to ASCII characters.

Source 1 | Source 2

like image 175
Gytis TG Avatar answered Apr 03 '26 09:04

Gytis TG


I would definitely change them to camel case, pascal case or whatever else closer to coding conventions/standards. It may work either way, but...better be safe than sorry.

like image 23
Konstantinos Vytiniotis Avatar answered Apr 03 '26 08:04

Konstantinos Vytiniotis



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!