The page does not jump
猫熊不说话
猫熊不说话 2017-10-19 13:00:52
0
2
1422
<?php
if(isset($_GET['action']))
{
	if($_GET['action'] == 'login')
	{
		if ($_POST['name']=='admin'&& $_POST['pwd']==123456 )
		{
			setcookie('userName',$_POST['name'],time()+3600*24);
			header('Location:index.php');
		}else
		{
			echo '<script> alert("用户名或密码不对");</script>';
		}
	}
	elseif ($_GET['action'] == 'logout')
		{
			setcookie('userName','',time()-3600);
		}
}
?>

<!DOCTYPE html> 
<html>
	<head>
		<meta charset = "utf-8">
		<title>用户登陆</title>
	</head>
	<body>
		<form action = "<?php echo $_SERVER['PHP_SELF'];?>?action = login" method = "post">
			<fieldset>
				<legend>用户登陆:</legend>
				<label for = "name">用户名: </label>
				<input type = "text" name = "name" id = "name">
				<label for = "pwd">密码: </label>
				<input type = "password" name = "pwd" id = "pwd">
				<input type = "submit" value = "提交">
			</fieldset>
		</form>
	</body>
</html>


猫熊不说话
猫熊不说话

开心点,人间不值得

reply all(2)
寻觅 beyond
<form action = "<?php echo $_SERVER['PHP_SELF'];?>?action = login" method = "post">

There cannot be spaces in the url. If there are spaces, the spaces will be encoded as a certain character, which is equivalent to ?action%=%login. Just delete the spaces on both sides of the equals symbol

  • reply thanks, thanks. I'm so stupid
    猫熊不说话 author 2017-10-19 13:16:52
  • reply Reply: The panda is silent: They are all people who have been here before. When I was a beginner, I also encountered such a situation
    寻觅 beyond author 2017-10-19 13:18:07
  • reply Reply Xunmi beyond: Well I will remember this bug
    猫熊不说话 author 2017-10-19 13:19:56
路过

How come you are redirected to the current page

  • reply I typed according to the video, www.php.cn/code/14805.html jumped in the video
    猫熊不说话 author 2017-10-19 13:13:47
  • reply Reply Panda does not speak:action = login "="There must be no spaces before and after. I have not watched the video.
    路过 author 2017-10-19 13:17:25
  • reply Reply Passing by: Yeah, yeah, yeah, it’s been solved, thank you, I’m so stupid
    猫熊不说话 author 2017-10-19 13:19:27
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template