deal with escape characters, magic quotes, and prevent sql-injection
[openemr.git] / library / formdata.inc.php
blob348e5e251f208a55134148c72a7548742ff561a4
1 <?php
2 // Copyright (C) 2009 Rod Roark <rod@sunsetsystems.com>
3 //
4 // This program is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU General Public License
6 // as published by the Free Software Foundation; either version 2
7 // of the License, or (at your option) any later version.
9 function formData($name, $type='P') {
10 if ($type == 'P')
11 $s = isset($_POST[$name]) ? $_POST[$name] : '';
12 else if ($type == 'G')
13 $s = isset($_GET[$name]) ? $_GET[$name] : '';
14 else
15 $s = isset($_REQUEST[$name]) ? $_REQUEST[$name] : '';
16 if (get_magic_quotes_gpc()) {$s = stripslashes($s);}
17 $s = mysql_real_escape_string($s);
18 return $s;
21 function formTrim($s) {
22 if (get_magic_quotes_gpc()) {$s = stripslashes($s);}
23 $s = mysql_real_escape_string($s);
24 return trim($s);