将登录凭据附加到URL

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了将登录凭据附加到URL相关的知识,希望对你有一定的参考价值。

The example here is if you had a form on a website that when submitted, needed to use that information to go to a special URL where the login information was all appeneded to the URL. (ex : <a href="http://giochionline1.123homepage.it"> giochi online 1 </a> ) You could have the form post with method GET, but that is limited to the typical ?variable=foo&variable2=bar format.

html Form
Typical form with three bits of information that submits to a file called ftp.php

PHP file
This file reads in the POST variables (if they are set), builds the URL from them, and redirects to it. You'd probably want to clean up the POST variables for security purposes.
  1. <!-- Html Form -->
  2.  
  3. <form action="../processing/ftp.php" method="post">
  4. <p><label for="ftp-company-name">Company</label><input type="text" name="ftp-company-name" id="ftp-company-name" /></p>
  5. <p><label for="ftp-user-name">User Name</label><input type="text" name="ftp-user-name" id="ftp-user-name" /></p>
  6. <p><label for="ftp-password">Password</label><input type="password" name="ftp-password" id="ftp-password" /></p>
  7. <p><input type="submit" id="ftp-submit" class="button" value="submit" /></p>
  8. </form>
  9. <!-- Html Form -->
  10. <!-- Php Form -->
  11. <?php
  12.  
  13. if (isset($_POST["ftp-company-name"])) {
  14.  
  15. $company = $_POST["ftp-company-name"];
  16. $username = $_POST["ftp-user-name"];
  17. $password = $_POST["ftp-password"];
  18.  
  19. $url = "ftp://$username:$password@ftp2.edgeconsult.com/$company";
  20.  
  21. header( "Location: $url" ) ;
  22.  
  23. } else {
  24.  
  25. // do nothing
  26.  
  27. }
  28.  
  29. ?>
  30. <!-- Php Form -->

以上是关于将登录凭据附加到URL的主要内容,如果未能解决你的问题,请参考以下文章

通过 facebook 登录会附加一些代码来重定向 url

如何将查询参数附加到现有 URL?

java 简单的代码片段,展示如何将javaagent附加到运行JVM进程

HttpResponseRedirect将传递的URL附加到当前URL

在Ansible中,凭据附加到Active Directory的计算机被拒绝

302 登录重定向后被 IE 删除的 URL 片段