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?
在PHP MySQL中将用户名传递给url
- 写回答
- 好问题 0 提建议
- 关注问题
- 邀请回答
-
4条回答 默认 最新
dtuqxb3884 2013-04-25 22:35关注There shouldn't really be a problem doing this. You could simply use a
POSTmethod that points to a URL with aGETparameter.So you make a
POSTrequest 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.
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报