blob: f5d5a4fc5339431072c18722664917dbf18f2eb3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
<?php
//This file will contain input validation functions.
function valid_keyval($keyval)
{
$keyval = trim($keyval);
$keyval = stripslashes($keyval);
$keyval = htmlspecialchars($keyval);
//check if keyval contains only uppercase or lowercase letters.
if (!preg_match('/^[a-zA-Z]+$/',$keyval)) {
header("Location: keyval_error.php");
}
if (strlen($keyval)!=3) {
header("Location: keyval_error.php");
}
return $keyval;
}
function valid_input($input)
{
$input = trim($input);
$input = stripslashes($input);
$input = htmlspecialchars($input);
//check if keyval contains only letters, numbers, hyphens, underscore, periods, or whitespace.
if (!preg_match('/^[-A-Za-z\d\ \t\r\n_\.\-]+$/',$input)) {
header("Location: input_error.php");
}
return $input;
}
|