|
|
|
|
Like this code?
Show the author your appreciation.
|
|
| |
Automagically add slashes to $_POST variables.
It helps to prevent some sql injection attacks.
Also works with $_GET variables.
input_cl.php
|
<?php
//create array to temporarily grab variables
$input_arr = array();
//grabs the $_POST variables and adds slashes
foreach ($_POST as $key => $input_arr) {
$_POST[$key] = addslashes($input_arr);
}
?> | |
Just put this at the top of your script that gets the variables. Here is an example.
Usage Example
| <?php
include("input_cl.php");
// all $_POST variables have slashes added to them
$f_name = $_POST["f_name"];
$l_name = $_POST["l_name"];
$phone_num = $_POST["phone_num"];
$address1 = $_POST["address1"];
$address2 = $_POST["address2"];
$city = $_POST["city"];
$State = $_POST["State"];
$zip = $_POST["zip"];
//sql insert code goes here. | | |
|
| Forms protected from XSS attacks (FOPAXSS) Categories : PHP, PHP Classes, Form Processing, Security | | | send_mail function to defeat Header Injection Hacking/Spamming Categories : PHP, Email, Form Processing, Security | | | Creates a CAPTCHA image in PHP, which displays 5 numbers stored in a session. Categories : PHP, GD image library, Form Processing, Security | | | A damaged image generator (class) for validating text.
CAPTCHA - Completely Automated Public Turing test to tell Computers and Humans Apart Categories : PHP, PHP Classes, Security, GD image library, Security | | | A few functions to create random passwords. Categories : PHP, Security, Strings | | | Scramble Eggs - php class to scramble/encode Categories : PHP, PHP Classes, Security, Encryption | | | PHP Function to Encrypt/Decrypt a string without a known key. The string itself has his own different key for every character. Categories : PHP, Algorithms, Security, Authentication, Encryption | | | Antispoof - a class to help prevent people hi-jacking and misusing parts of a website Categories : PHP, PHP Classes, Security | | | filter untrusted GET and POST variables and create trusted variable of same name Categories : PHP, Global Variables, Security | | | A captcha image allows you to prevent spam posting when users reload the page and stop bots from submitting forms automatically. This version allows you to use your own fonts (.ttf) to show the text.
Categories : PHP, Security, Graphics, GD image library | | | Human readable PHP password generator Categories : PHP, Security, Beginner Guides, Arrays | | | Secure URL $_GET Categories : PHP, Data Validation, Security | | | IPhider Obscure Any URL Anonymity connection lores obfuscation corporate survival. Categories : PHP, Algorithms, Security, URLs | | | Db_lib - practical example usage of database abstraction and form validation.
Categories : PHP, Form Processing, PHP Classes, Data Validation, Beginner Guides | | | send php mail with form data and attachment. Categories : PHP, Email, Mail, Form Processing | |
| | | | Dave Silvia wrote : 1664
I don`t quite understand. Aren`t slashes added by the request mechanism for posting from forms? My experience has been having to remove them, not add them.
I must be missing a point here somewhere...
| | | | Aaron Mitcham wrote :1665
Wouldn`t stripslashes($input_arr)work just as well?
Besides in every piece of code I`ve written I had to add slashes so that punctuation doesn`t break the script.
Aaron
| |
|
|