0

我正在尝试为 Openfire XMPP 服务器创建一个注册页面。最简单的方法似乎是使用用户服务插件来注册帐户,它可以让您使用 HTTP 请求注册用户。

本质上,我需要发出 HTTP 请求,例如

http://hostname:9090/plugins/userService/userservice?type=add&secret=passcode&username=kafka&password=drowssap&name=franz&email=franz@kafka.com

它将kafka使用密码drowssap、名称franz等注册用户。

所以在我看来,最好的方法是创建一个收集用户信息的 HTML 表单,然后发出 HTTP 请求。这似乎很简单,但我不确定最好的起点是哪里。php?Python?得到?猞猁?我不太确定如何在 HTML 表单中使用它们。

谢谢。

4

1 回答 1

0

永远不要以这种方式包含敏感数据。这是一个 GET 请求。您需要一个 POST 请求(不包括 URL 中的数据)。

你的 HTML 应该是这样的:

<form action="saveData.php" method="post">
    <input type="text" name="username" />
    <input type="password" name="password" />
    <!-- other inputs here -->
    <input type="submit" value="Create user" />
</form>

该表单将 POST 数据发送到 saveData.php 脚本。该脚本应该处理参数并重定向到另一个页面。

<?php
    // Here process the data the way you want (using data inside $_POST array, i.e. $_POST['username'], $_POST['password'], etc...
    // Usually you'd want to save to a database
   // When done, redirect to "success" page
   header("Location: success.php");
?>

您的 success.php 页面可以包含任何内容:

<?php
    echo "User created successfully!";
?>
于 2013-06-04T00:46:08.623 回答