PHP如何不用表单进行POST传递?

PHP如何不用表单进行POST传递


喵喔喔
浏览 1260回答 4
4回答

慕田峪7331174

在用户名 密码验证页面,<?php/////////if ( /*用户名密码验证失败*/ ){?><form id="form1" name="form1" method="post" action="login.php"><input name="login" type="hidden" id="login" value="fall" /></form><script language="JavaScript" type="text/javascript">document.getElementById("form1").submit();</script><?phpexit();//表单自动post提交}?>方法二<?phpsession_start();/////////if ( /*用户名密码验证失败*/ ){$_SESSION['login'] = 'fall';header('location:login.php');exit();}?>在login.php<?phpsession_start();if ($_SESSION['login'] == 'fall' ){echo '<a>登陆失败</a>';$_SESSION['login'] = '';}?>方法三:<?phpif ( /*用户名密码验证失败*/ ){setcookie("login","fall",time()+7200,"/");header('location:login.php');exit();}?>在login.php<?phpif ($_COOKIE['login'] == 'fall' ){echo '<a>登陆失败</a>';$_SESSION['login'] = '';}?>

Helenr

你把登陆信息存放在session中,在login文件里判断$_SESSION("??")是否等于成功登录的判断值,如果不是就显示<a>登录失败</a>

慕村225694

1234567[php]<form&nbsp;id="form1"&nbsp;name="form1"&nbsp;method="post"&nbsp;action="bbb.php">&nbsp;&nbsp;<input&nbsp;type="hidden"&nbsp;name="hiddenField"&nbsp;&nbsp;value="<?php&nbsp;echo&nbsp;$aaaa;?>"/></form><script&nbsp;&nbsp;&nbsp;language="javascript">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;document.form1.submit();&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</script>[/php]
打开App,查看更多内容
随时随地看视频慕课网APP