---
title: "How to prevent form hijacking in PHP?"  
description: "How to prevent form hijacking in PHP?"  
author: "Anonymous User"  
published: 2011-06-13  
updated: 2020-09-24  
canonical: https://www.mindstick.com/interview/1061/how-to-prevent-form-hijacking-in-php  
category: "php"  
tags: ["php"]  
reading_time: 2 minutes  

---

# How to prevent form hijacking in PHP?

**We take following steps to prevent form hijacking in php.**

1. Make register_globals to off to prevent Form Injection with malicious data.\
2. Make Error_reporting to E_ALL so that all variables will be intialized before using them.\
3. Make practice of using htmlentities(), strip_tags(), utf8_decode() and addslashes() for filtering malicious data in php\
4. SQL injection attacks by using mysql_escape_string().\
5. User Input Sanitization-Never trust web user submitted data. Follow good clieint side data validation practices with regular expressions before submitting data to the serve.\
6. Form Submision Key Validation: A singleton method can be used to generate a Session form key & validating form being submitted for the same value against hidden form key params.

## Answers

### Answer by Anonymous User

**We take following steps to prevent form hijacking in php.**

1. Make register_globals to off to prevent Form Injection with malicious data.\
2. Make Error_reporting to E_ALL so that all variables will be intialized before using them.\
3. Make practice of using htmlentities(), strip_tags(), utf8_decode() and addslashes() for filtering malicious data in php\
4. SQL injection attacks by using mysql_escape_string().\
5. User Input Sanitization-Never trust web user submitted data. Follow good clieint side data validation practices with regular expressions before submitting data to the serve.\
6. Form Submision Key Validation: A singleton method can be used to generate a Session form key & validating form being submitted for the same value against hidden form key params.


---

Original Source: https://www.mindstick.com/interview/1061/how-to-prevent-form-hijacking-in-php

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
