[英]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.