Very good advice from other members here, I can add that I would advise you to turn off register_globals in php.ini on your development php installation (and on production also if possible) so that you will NOT be able to use $something instead of $_POST['something'] - this will make you code in the proper way from the start.
What nextpr suggests can be also achieved with extract() function, which will extract all array values to local variables - don't do it and don't use it unless you have very good reason to, which is very rare in practice. And this not only applies to $_POST and $_GET but also to other arrays you may be using. If you have an array with data don't extract all the values to access them by direct variables - access them through the original array. For example, instead of:
PHP Code:
// fetch a row of data from database into array
$row = mysqli_fetch_assoc($db, $result);
extract($row);
// unit_price and quantity are fields fetched from db
$ext_price = $unit_price * $quantity;
do this, which is much more descriptive:
PHP Code:
// fetch a row of data from database into array
$product = mysqli_fetch_assoc($db, $result);
// unit_price and quantity are fields fetched from db
$ext_price = $product['unit_price'] * $product['quantity'];
I was also guilty of using the former method in all of my code a few years ago and trying to understand what's going on after more than a week later is a nightmare. The few seconds you will lose now on typing a few more characters will save you headaches when you look at your code a few months later.
Bookmarks