使用表单值在另一个网站上创建帐户 [英] using a form values to create an account on another website

查看:79
本文介绍了使用表单值在另一个网站上创建帐户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好我有以下代码:

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Registration Form</title>

<script type="text/javascript">
function validateForm() {
    var x = document.forms["myForm"]["uname"].value;
    var y = document.forms["myForm"]["pass"].value;
    if (x == null || x == "") {
        alert("UserName must be filled out");
        return false;
    }
    if (y == null || y == "") {
        alert("Password must be filled out");
        return false;
    }
}
</script>

</head>
<body>
    <h2> Register new GreenHouse </h2>
    <div>
    <form id="login" name= "myForm" method="put" action="" onsubmit="return validateForm()">
        <fieldset id="inputs">
            <input name="uname" id="username" type="text" placeholder="Username" autofocus required>   
            <input name="pass" id="password" type="password" placeholder="Password" required>
        </fieldset>
        <fieldset id="actions">
            <input type="submit" id="submit" value="Log in">
        </fieldset>
        </form>
    </div>
</body>
</html>

我希望能够使用用户名和密码的值,并在其他网站上创建一个新帐户(比如雅虎或谷歌)。我不太清楚如何开始这样做。当有人在文本框中填入一个具有相同用户ID和密码(如他们放入)的新帐户时,将为他们创建基本思路。如果有人能给我指路或给我一个关于此的教程,我会很高兴。

I want to be able to use values of username and password and create a new account at another website (such as yahoo or google). I am not quite sure how to start doing this. The basic idea when someone fill in the text-boxes a new account with the same userID and password (as they put in) will be created for them. I would be glad if someone could show me the way or show me a tutorial about this.

推荐答案

围绕在​​Google或Yahoo上创建用户帐户存在道德和可能的法律(以及技术)问题你建议的方式。用户应该直接创建帐户。

There are ethical and possibly legal (as well as technical) issues surrounding the creation of a user account on Google or Yahoo in the manner you suggest. The user should just create the account directly.

您可以通过整理Javascript来继续前进,如下所示:)

You can move forward, though, by tidying up your Javascript as follows :)

function validateForm() {
    var form = document.forms.myForm,
        x = form.uname.value,
        y = form.pass.value;

    if (x === null || x === "") {
        alert("UserName must be filled out");
        return false;
    }
    if (y === null || y === "") {
        alert("Password must be filled out");
        return false;
    }
}

编辑(根据您的评论):

EDIT (in light of your comment):

如果您拥有第二个网站,那么道德和法律问题就会消失。如果两个站点都托管在同一台服务器上,并且您可以直接访问数据库,则创建该帐户的网站无关紧要。

If you own the second website, then the ethical and legal issues disappear. If both sites are hosted on the same server and you have direct access to the database, it really doesn't matter which website the account is created through.

这篇关于使用表单值在另一个网站上创建帐户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆