doudu9652 2010-04-12 09:35
浏览 95
已采纳

密码错误时,请在用户名字段中保留用户

How do many of the websites that have logins keep the username in the username field when the password is entered incorrectly. The form's action (it is on index.php) is another php file, which if the password is incorrect uses Header() to go back to the index and passes the error to it using GET. I could use GET to pass the username back to the form but this seems messy, and I have noticed that websites like SMF forums have the username stay in the username field without a messy URL.

  • 写回答

4条回答 默认 最新

  • doulin6761 2010-04-12 09:38
    关注

    You can use sessions.

    For example, when a post is incorrect (this would go in the file processing your post request):

    $_SESSION['username'] = $_POST['username'];

    Then on your login page:

    <input type="text" name="username" value="<?php echo @$_SESSION['username']; ?>" />

    Make sure you start the session though: http://php.net/session_start

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

报告相同问题?

悬赏问题

  • ¥15 运筹学排序问题中的在线排序
  • ¥15 关于#flink#的问题:关于docker部署flink集成hadoop的yarn,请教个问题flink启动yarn-session.sh连不上hadoop
  • ¥30 求一段fortran代码用IVF编译运行的结果
  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 lammps拉伸应力应变曲线分析
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题