简体   繁体   English

我如何发送站点用户登录信息而不重定向到该站点?

[英]How do I send a site user login information without being redirected to that site?

I have a form that collects a user's username and password for a third-party site. 我有一个收集第三方站点用户名和密码的表单。 Only when the login information works do I want to proceed on my site. 仅当登录信息有效时,我才想在我的网站上继续。 My problem is that I currently have it set up as a form with the action link the third-party and when they click on the button, it just redirects them to the other site. 我的问题是,我目前将其设置为带有第三方操作链接的表单,当他们单击按钮时,它将它们重定向到另一个站点。 How can I only test that the username and password succeeds on the page without sending them to the page? 如何仅测试用户名和密码在页面上成功而不将其发送到页面? Is there a way with PHP? PHP有办法吗?

Yes there is -> curl extension or http_post_data() ( or http_post_fields() part of pecl_http extension). 是的,有-> curl扩展名http_post_data() (或pecl_http扩展名的http_post_fields()部分)。 There are examples too. 也有例子。 Depending on third-party site returned html/cookies/etc proceed the process or draw an error message. 根据第三方网站返回的html / cookies / etc继续执行此过程或绘制一条错误消息。

Yes. 是。 You have it post the login information to your page first. 您首先将登录信息发布到页面上。 Your page then curl's (or some other way of getting a remote page, such as http_post_data) that third party page, and checks of the login worked or not. 然后,您的页面卷曲(或通过其他某种方式获取远程页面,例如http_post_data)该第三方页面,并检查登录是否有效。 You may also then have to hit that third party page a second time, to log you out (if it preserves the login, that would be bad). 然后,您可能还不得不再次点击该第三方页面以注销您(如果保留了登录名,那将是不好的)。

Anyway, after it returns, you can then process the page as a login success or failure. 无论如何,返回后,您可以将页面作为登录成功或失败进行处理。

This could be done with jQuery, avoiding any server-side complications. 可以使用jQuery完成此操作,避免了服务器端的麻烦。 You could submit the form via the .post event , and read the response body to see if it was successful or not (they will probably have a success page, perhaps a user home page, or error page). 您可以通过.post事件提交表单,并阅读响应正文以查看表单是否成功(它们可能会有一个成功页面,也许是用户主页或错误页面)。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Laravel @ SSL注册或登录后,用户重定向到站点 - Laravel @ SSL after registration or login, user redirected to site/s 将DotNetNuke用户信息作为登录名传递到PHP站点 - Pass DotNetNuke User Information To PHP Site As Login 如何在不离开我的网站的情况下将变量从我的网站传递到另一个网站? - How do I pass Variables from my site to another site without leaving my site? 登录后如何将用户引导到另一个站点? - How can I lead a user to another site after login? 如果一个人在移动设备上,如何使用php或JavaScript将他们重定向到我的移动网站? - How do I use php or JavaScript to make a person be redirected to my mobile site if they are on a mobile? 如何通过使用PHP / CURL的POST通过登录网站 - How do I login to a site via a POST utilizing PHP/CURL 如何通过 url 提供 wordpress 站点的登录信息? - How do I supply the login to a wordpress site through a url? 如果 email 未验证,如何对用户是否被重定向到登录页面进行单元测试 - How to unit test if the user is being redirected to login page if email not validated 我怎样才能被重定向到管理面板旅行而不是网站的主页? - how can I be redirected to the admin panel to travel and not to the main page of the site? Symfony 4:如何排除故障/解释如果从外部链接访问站点,用户被强制登录 - Symfony 4: How to troubleshoot / explain User being forced to login if visitng site from external link
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM