【问题标题】:Taking data from 1 website(input) and pasting it to another website(input)从 1 个网站(输入)获取数据并将其粘贴到另一个网站(输入)
【发布时间】:2019-05-28 05:57:57
【问题描述】:

我需要获取用户名的数据,然后签入数据库,aunthefecator 用户拥有并依赖 aunthefecator 向他发送可以输入并登录帐户的窗口!

我试图让它像一个 1 表单,并且该方法被发送到另一个表单但它不起作用。

<form name="logon" action="check_login.php" method="POST" id="login">
  <input type="text" name="username">
  <input type="password" name="password">
  <button type="submit">                                 
    <span>Log IN</span>
  </button>
</form>

我只是在这个页面上重定向而没有获取数据。

【问题讨论】:

  • 这只会提交到另一个页面并使用来自另一个页面的结果重新加载窗口。
  • 如果你想发送到那个页面而不重新加载,你需要使用AJAX,然后解析响应。
  • 与其发送到另一个网页,不如实现一个可供所有人用于单点登录的 API。
  • 我对 API 不好,是什么样的?这就像与网络服务器的安全连接?
  • 这是一个网络服务器脚本,响应是数据而不是 HTML,JSON 是一种常见格式。

标签: javascript php html ajax web


【解决方案1】:

您必须将此代码放在您的php页面顶部,或者如果您想在另一个页面中检查登录,您应该将此代码放在您要检查登录身份验证的目标页面中。请记住将您的代码用于检查用户并从数据库中传递。

<?php
if(isset($_POST[“username”] && $_POST[“password”]){
$user = $_POST[“username”];
$pass = $_POST[“password”];
//Check your db here and then replace your url that you want to reload client if user and pass was correct.
header(‘Location: http://yourURL.com’);
}else{
echo (“username or password was not correct”);
}
?>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-08-15
    • 1970-01-01
    • 2021-09-03
    • 1970-01-01
    相关资源
    最近更新 更多