note 99881 deleted from function.mysql-real-escape-string by danbrown
| From: | danbrown@php.net | Date: | Mon, 13 Sep 2010 21:40:44 +0000 |
| Subject: | note 99881 deleted from function.mysql-real-escape-string by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-172528@lists.php.net to get a copy of this message | ||
Note Submitter: ricardo at ricardotorres dot co dot uk
----
That's what I do:
<?php
function clean($str) {
$str = @trim($str);
if(get_magic_quotes_gpc()) {
$str = stripslashes($str);
}
return mysql_real_escape_string($str);
}
?>
And then:
<?php
$username = clean($_POST['username']);
$password = clean($_POST['password']);
?>
Assuming - of course - that you have an open link with the database.