-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsoapserver.php
More file actions
77 lines (74 loc) · 2.36 KB
/
soapserver.php
File metadata and controls
77 lines (74 loc) · 2.36 KB
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<?php
header('Content-Type: text/html; charset=utf-8');
class Service {
public function getFlightInfo($dest,$src,$date){
$con = mysql_connect("localhost","root","fz1989");
$ret = "";
$header = "<p><table border='4'>
<tr>
<th>航班号</th>
<th>票价</th>
<th>剩余票数</th>
<th>起飞时间</th>
<th>降落时间</th>
</tr>";
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("webservice", $con);
$sql= "select * from flight where dest = '$dest' and src = '$src' and date ='$date'";
$result = mysql_query($sql);
while ($row = mysql_fetch_array($result))
{
if ($ret == "") {
$ret = $ret . $header;
}
$ret = $ret . "<tr>";
$ret = $ret . "<td>" . $row['flightNum'] . "</td>";
$ret = $ret . "<td>" . $row['Price'] . "</td>";
$ret = $ret . "<td>" . $row['remainNum'] . "</td>";
$ret = $ret . "<td>" . $row['utime'] . "</td>";
$ret = $ret . "<td>" . $row['dtime'] . "</td>";
$ret = $ret . "</tr>";
}
if ($ret == "") {
$ret = "<p>请重新在输入吧!</p>";
return $ret;
}
$ret = $ret . "</table></p>";
$ret = $ret . "<form name = \"BuyInfo\">
<p>航班号:<input type = \"text\" id = \"flightNum\" /></p>
<p>票数:<input type = \"text\" id = \"requireNum\" /></p>
<p><input type=\"button\" value=\"买票\" onClick=\"getBuyInfo()\"></p>
</form>
";
mysql_close($con);
return $ret;
}
public function getBuyInfo($flightNum, $needNum) {
$ret = "";
$con = mysql_connect("localhost","root","fz1989");
$ret = "";
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("webservice", $con);
$sql= "select * from flight where flightNum = '$flightNum'";
$result = mysql_query($sql);
$row = mysql_fetch_array($result);
if ($row['remainNum'] < $needNum) {
$ret = "<p>余票不足!</p>";
return $ret;
}
$ret = "购买航班号为" . $flightNum . "的" . $needNum . "张票,总计" . $needNum * $row['Price'];
$sql = "update flight set remainNum = remainNum - $needNum where flightNum = '$flightNum'";
$result = mysql_query($sql);
return $ret;
}
}
$server = new SoapServer(null,array('uri'=>"http://219.245.98.140"));//This uri is your SERVER ip.
$server->setClass("Service");
$server->handle();
?>