doubingguan3425 2011-08-29 22:35
浏览 29
已采纳

在php url中插入登录凭据?

I am trying to be able to log-in to a PHP webpage with the credentials in the URL.

Example:

http://www.mywebsite.com/logon.php?logon=user&password=password

The URL above inserts user and password into the text fields but does not submit the page and continue.

  • How do I submit a page via URL?
  • Is it possible? If not, sorry for the question.
  • 写回答

2条回答 默认 最新

  • doupan6648 2011-08-29 22:48
    关注

    There are two versions of the answer, here: how to do what you asked, and how to do what you actually want. Chances are you don't actually want to do it the way you asked, because passing the password in the URL field is a super-bad idea. To answer the question as asked, it goes like this:

    • To read the values out of the URL string, you can use the $_GET array. To print what logon is passed, do:

      echo($_REQUEST[logon]);
      

      To submit the data in the first place, you'll need to use a form. There are other methods, but this is the most basic. Something like this:

      <form action="logon.php" method="get">
      <input name="logon">
      <input name="password">
      <input type=submit value="Login">
      </form>
      
    • That being said, better practice would be to pass the password through the POST parameter, which at least isn't visible in the addressbar. To do this, simply substitute:

      <form action="logon.php" method="post">
      <input name="logon">
      <input name="password">
      <input type=submit value="Login">
      </form>
      
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 目详情-五一模拟赛详情页
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line