-
Notifications
You must be signed in to change notification settings - Fork 1
/
checkname.php
62 lines (55 loc) · 1.35 KB
/
checkname.php
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
require_once("parse_config.php");
require_once("common_lib.php"); //for sanity check
$host = $ini_array["host"];
$username = $ini_array["username"];
$password = $ini_array["password"];
$db = $ini_array["db"];
$port = "";
$socket = "";
DB::$user = $username;
DB::$password = $password;
DB::$dbName = $db;
DB::$host = $host;
//$link = mysqli_connect("localhost","root","","test");
$link = mysqli_connect($host, $username, $password, $db);
/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
$name=sanitize($_REQUEST["name"]);
$name = strtoupper($name);
//$name=$_GET["name"];
//$name="Sachin Filinto";
//$name="Testing";
//$name="soongwah";
//$name="Khatmalli Shah";
//$name="Khatmal Shah";
$result=mysqli_query($link, "SELECT vphone from visitor where UPPER(vname)='$name'");
if ($result) {
/* determine number of rows result set */
$row_cnt = $result->num_rows;
if ($row_cnt == 0) {
/* no results. */
return;
} else if ($row_cnt == 1) {
/* only one result, so we are sure. */
$row = mysqli_fetch_row($result);
echo($row[0]);
}
/* free result set */
mysqli_free_result($result);
}
/* close connection */
mysqli_close($link);
/*
if (0) {
} else {
// too many same names, unsure of result,
// return special value to indicate many matches.
echo $row_cnt;
return;
}
*/
?>