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 fluent的在模拟压强时使用希望得到一些建议
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services
  • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏
  • ¥15 模糊pid与pid仿真结果几乎一样
  • ¥15 java的GUI的运用
  • ¥15 Web.config连不上数据库
  • ¥15 我想付费需要AKM公司DSP开发资料及相关开发。
  • ¥15 怎么配置广告联盟瀑布流
  • ¥15 Rstudio 保存代码闪退