search

Home  >  Q&A  >  body text

The page does not jump

<?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>


猫熊不说话猫熊不说话2592 days ago1435

reply all(2)I'll reply

  • 寻觅 beyond

    寻觅 beyond2017-10-19 13:14:32

    <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
    0
  • 猫熊不说话

    thanks, thanks. I'm so stupid

    猫熊不说话 · 2017-10-19 13:16:52
    寻觅 beyond

    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 · 2017-10-19 13:18:07
    猫熊不说话

    Reply Xunmi beyond: Well I will remember this bug

    猫熊不说话 · 2017-10-19 13:19:56
  • 路过

    路过2017-10-19 13:11:12

    How come you are redirected to the current page

    reply
    0
  • 猫熊不说话

    I typed according to the video, www.php.cn/code/14805.html jumped in the video

    猫熊不说话 · 2017-10-19 13:13:47
    路过

    Reply Panda does not speak:action = login "="There must be no spaces before and after. I have not watched the video.

    路过 · 2017-10-19 13:17:25
    猫熊不说话

    Reply Passing by: Yeah, yeah, yeah, it’s been solved, thank you, I’m so stupid

    猫熊不说话 · 2017-10-19 13:19:27
  • Cancelreply