PHP登录页面重定向 [英] PHP Login Page Redirect
本文介绍了PHP登录页面重定向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
此代码不完整,我需要它重定向到名为mainpage.php的页面,其中包含用户名和密码的硬编码信息.这是代码.
this code is incomplete and I need it to redirect to a page called mainpage.php with hardcoded information for the username and password. Here's the code.
<?php
session_start();
$username="user";
$password="123";
if($_POST['username'] == $username && $_POST['password'] == $password)
?>
<html>
<head>
</head>
<body>
<div style='text-align:center'>
<h3>Welcome To Kontak</h3>
</div>
<hr /><br />
<form id='login' action="" method='post' accept-charset='UTF-8'>
<fieldset style="width:550px">
<legend>Admin Login</legend>
<input type='hidden' name='submitted' id='submitted' value='1'/>
<label for='username' >UserName:</label>
<input type='text' name='username' id='username' maxlength="50" />
<label for='password' >Password:</label>
<input type='password' name='password' id='password' maxlength="50" />
<input type='submit' name='submit' value='Submit' />
</fieldset>
</form>
</body>
</html>
推荐答案
我认为您正在寻找:
if($_POST['username'] == $username && $_POST['password'] == $password)
header( 'Location: mainpage.php' );
?>
因此,如果满足条件,则标头将转至mainpage.php. -维杰
so the header will take to mainpage.php when if condition is satisfied. --Vijay
这篇关于PHP登录页面重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文