0

I have a simple html form where I am capturing three variables from the user, first is the registration number second is the date of joining and the last one is password. When I use

$regdno=$_POST["regdno"];
$doj=$_POST["doj"] ;
$password=$_POST["password"];echo $regdno;
echo $doj;
echo $password;

I am getting results printed like

113128321985/12/06myownpass

when I am using Internet explorer, firefox and opera which is correct. But when I am using Google Chrome it is showing like this

11312832 1985/12/06myownpass

Which is showing an extra blank space. Friends Why is this difference and how to rectify it?

Geert
  • 1,217
  • 8
  • 20
sdk
  • 1
  • 3

2 Answers2

0

Try using trim() in each variables

Alfred Woo
  • 648
  • 1
  • 6
  • 23
0

Since each browser parses and validates HTML differently. Generally speaking, if you are noticing different results in form data between browsers it is probably caused by an invalid HTML issue. Where the browser interpreted how to fix the HTML differently than the others. Try validating your HTML code on W3: https://validator.w3.org/

It could also be caused by autocomplete data including a white-space in a previously saved value.

Lastly you should always sanitize and validate any user supplied data, no matter how trivial the information supplied is. What's the best method for sanitizing user input with PHP?

Community
  • 1
  • 1
Will B.
  • 17,883
  • 4
  • 67
  • 69