PHP会话变量而不是GET方法
我有一个包含姓名、ID、地址等的表单。用户输入 ID 后需要刷新,以便查询和检索其他信息,例如基于输入 ID 的专业。 刷新后,我通过 Get 方法检索输入的值,以便保留输入的表单值。 如下所示,
<?php
$_SESSION['Bid']=@$_GET['Bid'];
$_SESSION['Stufname']=$_GET['fname'];
$_SESSION['Stulname']=$_GET['lname'];
?>
<form name="form1" method="post" action="registration.php" >
<input type="text" name="Bid" value="<?php echo $_SESSION['Bid'];?>"
MAXLENGTH=9 size="9">
</form>
一切正常,但我知道 GET 方法不安全,因为变量现在显示在 URL 中,我想避免使用 get。 我在其他脚本中尝试了会话变量,但在这种情况下,因为页面在输入 ID 后刷新,所以我不太确定如何在页面刷新时捕获和存储会话变量中的表单值,而不像上面那样使用 GET 方法。
任何帮助将不胜感激。 谢谢,
I have a form that has name, Id, address etc. It needs to refresh after user enters the ID inorder to query and retrieve other information such as major based the entered ID.
Once it refreshes, I retrieve back the entered values via Get method so to retain the entered form values.
Shown below
<?php
$_SESSION['Bid']=@$_GET['Bid'];
$_SESSION['Stufname']=$_GET['fname'];
$_SESSION['Stulname']=$_GET['lname'];
?>
<form name="form1" method="post" action="registration.php" >
<input type="text" name="Bid" value="<?php echo $_SESSION['Bid'];?>"
MAXLENGTH=9 size="9">
</form>
All works fine but i know GET method is unsecure since the variables are now shown in the URL and I want to get away from using get.
I tried session variable in other scripts but in this case, because the page refreshes after entering ID, I am not really sure how to capture and store the form values in the session variables on page refresh without using the GET method as I did above.
Any help would be appreciated.
thanks,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用 POST 代替。您可以从这里找出语法: http://www.w3schools.com/ php/php_post.asp 但我建议在发布问题之前进行更多研究。
You can use POST rather. You'll be able to figure out the syntax from here: http://www.w3schools.com/php/php_post.asp but I'd recommend doing more research before posting a question.