WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDES  |  PHP CLASSES  |  CODE SEARCH  |  ARTICLES SEARCH  |  PHP FORUMS  |  PHP MANUAL  |  PHP FUNCTIONS LIST  |  WEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Submit Your Code
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
WeberDev's Monthly code contest PHP Code Contest
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Index
Web Development Resources
Web Development Content
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
User Submitted Data

User Submitted Data

The greatest weakness in many PHP programs is not inherent in the language itself, but merely an issue of code not being written with security in mind. For this reason, you should always take the time to consider the implications of a given piece of code, to ascertain the possible damage if an unexpected variable is submitted to it.

Example #1 Dangerous Variable Usage

<?php
// remove a file from the user's home directory... or maybe
// somebody else's?
unlink ($evil_var);

// Write logging of their access... or maybe an /etc/passwd entry?
fwrite ($fp$evil_var);

// Execute something trivial.. or rm -rf *?
system ($evil_var);
exec ($evil_var);

?>

You should always carefully examine your code to make sure that any variables being submitted from a web browser are being properly checked, and ask yourself the following questions:

  • Will this script only affect the intended files?
  • Can unusual or undesirable data be acted upon?
  • Can this script be used in unintended ways?
  • Can this be used in conjunction with other scripts in a negative manner?
  • Will any transactions be adequately logged?

By adequately asking these questions while writing the script, rather than later, you prevent an unfortunate re-write when you need to increase your security. By starting out with this mindset, you won't guarantee the security of your system, but you can help improve it.

You may also want to consider turning off register_globals, magic_quotes, or other convenience settings which may confuse you as to the validity, source, or value of a given variable. Working with PHP in error_reporting(E_ALL) mode can also help warn you about variables being used before they are checked or initialized (so you can prevent unusual data from being operated upon).


Problem passing session variables
Categories : Sessions, PHP
clearing variables in php3
Categories : Variables, Arrays, PHP
A simple configuration file editor to ease you life in setting up php applications. Reads variables from a given file automatically and displays current value. New value will be written to file after submit.
Categories : PHP, Filesystem, Regexps, Java Script



Simple PHP program which calls other PHP program you can pass the variables to other PHP program : by Raju
Categories : PHP, PHP Options and Info, Regexps, Program Execution
WHOIS is a class to make your life easier in case you use a lot of APACHE PREDEFINED VARIABLES.
Categories : PHP, PHP Classes
A variable variables example
Categories : PHP, Variables
addslashes automatically to $_POST variables
Categories : PHP, Form Processing, Security
PHP Dump in html format the contents of one array variable with a recursive list of the nested array variables inside.
Categories : PHP, Arrays, Variables
How to display a PHP variable value from a selectbox without reloading the page by merging PHP and Javascript variables.
Categories : PHP, Java Script, Variables
filter untrusted GET and POST variables and create trusted variable of same name
Categories : PHP, Global Variables, Security
Include a file inside of a function and have the included variables be global.
Categories : PHP, Variables, Global Variables
Initialize global variables for every field in a table. This is the generic version. It does not require phplib.
Categories : Global Variables, MySQL, PHP, Variables
Passing Variables By Reference
Categories : PHP, Beginner Guides, Variables
IdealMySQL Database Class - Connect and Query a mysql database including INSERT | DELETE | UPDATE | REPLACE | DROP | SELECT | SHOW | DESCRIBE | EXPLAIN, Catch errors and email them,Check variables to make sure they only contain particular characters.
Categories : PHP, PHP Classes, Databases, MySQL