What are the potential pitfalls of trying to encrypt form data using MD5 before transmission?

Using MD5 to encrypt form data before transmission can be insecure because MD5 is a broken hashing algorithm that is vulnerable to collision attacks. This means that attackers could potentially create different inputs that produce the same MD5 hash, leading to data integrity issues. It is recommended to use more secure hashing algorithms like SHA-256 for encrypting sensitive data before transmission.

// Using SHA-256 to hash form data before transmission
$hashed_data = hash('sha256', $form_data);