gpt4 book ai didi

php - 如何通过 html 表单连接到我的服务器

转载 作者:行者123 更新时间:2023-11-29 13:07:19 26 4
gpt4 key购买 nike

我在移动应用程序上设置了一个简单的登录页面来接收用户名和密码。我还设置了一个服务器,如果我在网址上插入正确的密码和用户名,它会显示 {"loggedIn":true} 。我希望发生同样的想法,但这次我想在移动应用程序上插入密码/用户名信息。

这是服务器的网址:http://softwarehuttest.x10.mx/public/account/login/?id=param&password=param

url 中的参数将被 html 表单中的输入替换。我不确定如何在移动应用程序和服务器之间建立此链接。我知道这种连接方法不安全,稍后将尝试使用主题标签。我现在只是想建立连接。请建议我如何进行此连接。

我的html代码如下:

<div data-role="page" id="loginPage" data-theme="e"><!--Start of Log In Page-->
<header data-role="header">
<h1>Log In</h1>
</header>

<form id="form1" name="form1" method="post" action="">
<p>
<label for="username">UserName</label>
<input type="text" name="username" id="username" />
</p>
</form>

<form id="form2" name="form2" method="post" action="">
<label for="password">Password </label>
<input type="password" name="password" id="password" />
</form>
<input type="submit" name="login" id="login" value="Log In" />

<footer data-role="footer" data-position="fixed">
<h1></h1>
</footer>
</div><!--End of Log In Page-->

最佳答案

您可以使用以下内容;

 <form id="form2" name="form2" method="GET" action="http://softwarehuttest.x10.mx/public/account/login/">
<label for="password">Username </label>
<input type="text" name="username" id="username" />

<label for="password">Password </label>
<input type="password" name="password" id="password" />

<input type="button" name="submit" id="submit" value="Login"/>
</form>
<script>
$(document).ready(function() {
$("#submit").on("click", function() {
$.get( "http://softwarehuttest.x10.mx/public/account/login/", $("#form2").serialize(), function(data) {
alert(data);
});
});
});
</script>

关于php - 如何通过 html 表单连接到我的服务器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22530252/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com