App Inventor2 與PHP的傳值與傳回值(HTTP Post)

下圖是Designer的畫面,共有四個元件
Button1:確認
Button2:清除,把Label1設為88888
Label1:顯示值
web1:web元件,可以POST或GET


下圖是 Blocks的設計流程,主要在於呼叫PostText來上傳資料到PHP,此處用join來告知PHP上傳的變數名稱與值
,所以join的第一個值為test=,加上第二個的值,其字串為"test=bbbbbb;

如果想POST多個參數,在每個參數間以「&」為區別,如下:


模擬器執行的結果


PHP的測試語法(test01.php):
<?php
    echo $_POST["test"];
?>

下面是利用表單來測試test01.php是否運作是否正常:
<html>
<head>
<title>Test01_01</title>
</head>
<body>
<form action="test01.php" name="form" method="post">
<table width="600" border="1">
<tr>
<th width="91"> <div align="center">輸入值</div></th>
</tr>
<tr>
<td><div align="center"><input type="text" name="test"></div></td>
</tr>
</table>
<input type="submit" name="submit" value="submit">
</form>
</body>
</html> 

Windows 11安裝時跳過網路連線