This repository has been archived by the owner on Jun 15, 2020. It is now read-only.
forked from KennyYou/Stock_API_Trading
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuy.php
69 lines (52 loc) · 1.3 KB
/
buy.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
61
62
63
64
65
66
67
68
69
<!DOCTYPE HTML>
<html>
<body>
<div class="topnav">
<a class="active" href="loginsuccess.php">Home</a>
<a class="active" href="profile.php">Profile</a>
<a class="active" href="sell.php">Sell</a>
<a class="active" href="index.html">Logout<a>
</div>
<h2>Welcome to Stock Transaction</h2>
<br>
How many stocks do you want to buy?
<br>
<form method="POST">
<input type="text" name="amount" placeholder="Enter a amount" required><br>
<input type="text" name="symbol" placeholder="Enter a stock symbol" required><br>
<button type="submit"> Submit </button>
</form>
<?php
if(isset($_POST['amount'])){
session_start();
require_once('path.inc');
require_once('get_host_info.inc');
require_once('rabbitMQLib.inc');
$client = new rabbitMQClient("testRabbitMQ.ini","testServer");
if (isset($argv[1]))
{
$msg = $argv[1];
}
else
{
$msg = "buyStock";
}
//Send search request over
$request['search'] = $_POST['search'];
$request['message'] = $msg;
$request = array();
$request['type'] = "buyStock";
$request['username'] = $_SESSION["username"];
$request['amount'] = $_POST['amount'];
$request['symbol'] = $_POST['symbol'];
//Send msg
$request['message'] = $msg;
$response = $client->send_request($request);
//PHP_EOL should echo in from backend
echo "".PHP_EOL;
print_r($response);
echo"\n";
}
?>
</body>
</html>