duanmei4149 2013-04-25 22:30
浏览 50
已采纳

在PHP MySQL中将用户名传递给url

I am developing a site in PHP that allows users to sign up and enter in some information, and I would like to give each user a unique URL. When the user logs in to his profile, I want JUST the username to be passed to the URL (like www.mysite.com/profile.php?user=username) in order to rewrite it later. However, I'm using the $_POST method, and I'm concerned if I use $_GET while logging in the password will be passed to the URL as well. What should I do?

  • 写回答

4条回答 默认 最新

  • dtuqxb3884 2013-04-25 22:35
    关注

    There shouldn't really be a problem doing this. You could simply use a POST method that points to a URL with a GET parameter.

    So you make a POST request to:

    www.mysite.com/profile.php?user={$username}
    

    This way the user variable in the URL doesn't need to be used in the authentication.
    Consider this for a simplistic example:

    <form method="post" action="/profile.php?username=hasan">
      <input type="text" name="username" value="hasan" />
      <input type="text" name="password" value="********" />
    </form>
    

    The URL you are posting to doesn't have to be hard coded either - you could always dynamically add the user name before submitting the form.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 Llama如何调用shell或者Python
  • ¥20 谁能帮我挨个解读这个php语言编的代码什么意思?
  • ¥15 win10权限管理,限制普通用户使用删除功能
  • ¥15 minnio内存占用过大,内存没被回收(Windows环境)
  • ¥65 抖音咸鱼付款链接转码支付宝
  • ¥15 ubuntu22.04上安装ursim-3.15.8.106339遇到的问题
  • ¥15 blast算法(相关搜索:数据库)
  • ¥15 请问有人会紧聚焦相关的matlab知识嘛?
  • ¥15 网络通信安全解决方案
  • ¥50 yalmip+Gurobi