0

I am using multiple time $_POST['email'] so my simple question is should I store in another variable like $a = $_POST['email'] than use $a or $_POST doesn't affect that much.

gaurav
  • 75
  • 1
  • 8
  • Please go through this [link](http://stackoverflow.com/questions/1301863/what-are-the-vulnerabilities-in-direct-use-of-get-and-post) – Ashu Jha Aug 26 '16 at 12:04
  • 2
    You should always store it in another variable. It's best to make $email = someFiltersMaybe($_POST['email']);. Then every time when you use your variable $email you will be sure that you are using clean, filtered, correct data. It's best for optimization and especially security purposes. – g9m29 Aug 26 '16 at 12:05
  • and refer this http://stackoverflow.com/a/6334857/3164682 – Sarath Aug 26 '16 at 12:06
  • @g9m29 Thanks , i already using PDO prepare for that – gaurav Aug 26 '16 at 12:07
  • Filters are not only for SQL injection. – Sylwit Aug 26 '16 at 12:11

3 Answers3

0

yes its as simple as your question $_POST is a way of getting variable then you can store the value in any variable

$a= $_POST['email']; 
Mirza Obaid
  • 1,707
  • 3
  • 23
  • 35
0

Saving it to a variable would make your code more legible, and increase optimization.

Accessing the POST variable gives no advantages, apart from a slightly smaller source file and slightly less memory usage.

Jason
  • 61
  • 2
0

There's very little difference between using a variable and using elements in $_POST directly. Performance is about the same and you can make arguments in either direction from a readability perspective.

By the way, be careful with data from the user. Don't assume this has a valid email address in it.