我想将服务器连接到理货单。问题是,当我在“ LOCALHOST”中运行此代码时,它会在提示中插入数据,但是当我将该文件上传到服务器时,它将不会插入数据,任何人都可以帮助我。我认为问题出在URL,我不是运行该代码应提供的URL,我尝试过使用“ Domain_name.com”或“网站IP地址”无法正常工作。 谁能帮我吗?
if(count($_POST)) {
$group_name = strtoupper($_POST['group_name']);
$item_name = $_POST['item_name'];
/*$opening_balance = $_POST['opening_balance'];
$opening_value = $_POST['opening_value'];
$opening_rate = $opening_value * $opening_balance;*/
$res_str =<<<XML
<ENVELOPE>
<HEADER>
<TALLYREQUEST>Import Data</TALLYREQUEST>
</HEADER>
<BODY>
<IMPORTDATA>
<REQUESTDESC>
<REPORTNAME>All Masters</REPORTNAME>
</REQUESTDESC>
<REQUESTDATA>
<!-- Create Stock Group named "$group_name" -->
<TALLYMESSAGE xmlns:UDF="TallyUDF">
<STOCKGROUP NAME="{$group_name}" ACTION="Create">
<NAME.LIST>
<NAME>{$group_name}</NAME>
</NAME.LIST>
<PARENT/>
<ISADDABLE>Yes</ISADDABLE>
</STOCKGROUP>
</TALLYMESSAGE>
<!-- Create Stock Item named "$item_name" -->
<TALLYMESSAGE xmlns:UDF="TallyUDF">
<STOCKITEM NAME="{$item_name}" ACTION="Create">
<NAME.LIST>
<NAME>{$item_name}</NAME>
</NAME.LIST>
<PARENT>{$group_name}</PARENT>
<BATCHALLOCATIONS.LIST>
<NAME>Primary Batch</NAME>
<BATCHNAME>Primary Batch</BATCHNAME>
<GODOWNNAME>Main Location</GODOWNNAME>
<MFDON>20190120</MFDON>
<OPENINGBALANCE>0.000 NOS</OPENINGBALANCE>
<OPENINGVALUE>0.000</OPENINGVALUE>
<OPENINGRATE>0.000/NOS</OPENINGRATE>
</BATCHALLOCATIONS.LIST>
</STOCKITEM>
</TALLYMESSAGE>
</REQUESTDATA>
</IMPORTDATA>
</BODY>
</ENVELOPE>
XML;
//var_dump($res_str);die;
$url = "localhost:8000/";
//setting the curl parameters.
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
// Following line is compulsary to add as it is:
curl_setopt($ch, CURLOPT_POSTFIELDS,
"xmlRequest=" . $res_str);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 300);
$data = curl_exec($ch);
if(curl_errno($ch)){
var_dump($data);
} else {
$msg = $data;
}
curl_close($ch);
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<title>Tally</title>
<!-- Bootstrap -->
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<div class="container">
<div class="col-md-6 col-md-offset-3" style="margin-top:20px">
<?php if(isset($msg) && $msg) :?>
<div class="alert alert-success" role="alert"><?=$msg?></div>
<?php endif;?>
<div class="pull-left"><a href="export.php">Item List</a> | </div>
<div class="pull-left"><a href="stockGroupItem.php">Create StockGroup Item</a> | </div>
<div class="pull-left"><a href="ledger.php">Create Ledger</a> | </div>
<hr>
<form class="form-horizontal" method="post" action="">
<div class="form-group">
<label for="group-name" class="col-sm-4 control-label">Stock Group name</label>
<div class="col-sm-6">
<input type="text" class="form-control" id="group-name" placeholder="Stock Group name" name="group_name">
</div>
</div>
<div class="form-group">
<label for="item-name" class="col-sm-4 control-label">Stock Item name</label>
<div class="col-sm-6">
<input type="text" class="form-control" id="item-name" placeholder="Stock Item name" name="item_name" required>
</div>
</div>
<!-- <div class="form-group">
<label for="opening_balance" class="col-sm-4 control-label">Quantity</label>
<div class="col-sm-6">
<input type="text" class="form-control" id="opening_balance" placeholder="Item Quantity" name="opening_balance" required>
</div>
</div>
<div class="form-group">
<label for="opening_value" class="col-sm-4 control-label">Unit Price</label>
<div class="col-sm-6">
<input type="text" class="form-control" id="opening_value" placeholder="Item Unit Price" name="opening_value" required>
</div>
</div> -->
<div class="form-group">
<div class="col-sm-offset-4 col-sm-6">
<button type="submit" class="btn btn-primary">Insert</button>
</div>
</div>
</form>
</div>
</div>
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</body>
</html>```
答案 0 :(得分:0)
它在您的本地主机URL上运行的事实意味着您正在安装Tally的本地计算机上运行此html文件。如果将其放在服务器上会怎样?您的理货实例在本地计算机上运行,而html文件则在服务器上。现在,本地计算机具有一个LAN IP(例如IP 192.x),该IP隐藏在分配给路由器的主IP(例如A)的后面。但是,您的服务器位于另一个IP(例如B)。
(IP B处的)html文件如何知道如何对Tally进行ping操作?即使您提供了路由器的IP(位于IP A处)而不是本地主机URL,路由器也将如何知道您局域网中的哪些计算机实际上已经安装了Tally?
我使用http://localhost.run/运行了该测试,在该测试中,我允许在路由器上打开端口(特别是运行Tally的本地计算机上的localhost:9000),然后通过替换从服务器ping Tally本地主机URL和此网站生成的URL。
您可以尝试将其用于测试目的,尽管在生产环境中,您可能需要一个更可靠的解决方案(通过SSH或将Tally本身放在服务器上)。