I have two files. First file is a form and the second file displays result.
First file:
Use trim() instead of str_replace
trim()
str_replace