Jump to content

Is this overkill or good coding practice?


cunoodle2

Recommended Posts

Do you null set all variables at the top of your page?  I'm just trying to go over the top with my scripts as of recent to attempt to prevent any injections/bad things from happening.  Is this overkill or good coding practice...

 

<?php
###################################
#           NULL SET ALL VARIABLES                     #
###################################
$error = NULL;
$errornum = NULL;
$email = NULL;
$password = NULL;
$password2 = NULL;
$firstname = NULL;
$id = NULL;
$phone = NULL;

###################################
#             GET PASSED IN VALUES                     #
###################################
//these will all be sent in via the form submitted by the user
$firstname = isSet($_POST['firstname']) ? $_POST['firstname'] : NULL;
$password = isSet($_POST['password']) ? $_POST['password'] : NULL;
$password2 = isSet($_POST['password2']) ? $_POST['password2'] : NULL;
$email = isSet($_POST['email']) ? $_POST['email'] : NULL;

###################################
#                          CLEAN DATA                       #
###################################
$firstname = Clean($firstname);
$password = Clean($password);
$password2 = Clean($password2);
$email = Clean($email);
$error = Clean($error);
$errornum = Clean($errornum);

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.