PHP登录页面重定向

use*_*254 1 php login href

这段代码不完整,我需要它重定向到一个名为mainpage.php的页面,其中包含用户名和密码的硬编码信息.这是代码.

<?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>
Run Code Online (Sandbox Code Playgroud)

小智 5

我想你正在寻找这个:

if($_POST['username'] == $username && $_POST['password'] == $password)

header( 'Location: mainpage.php' );
?>
Run Code Online (Sandbox Code Playgroud)

如果条件满足,标题将转到mainpage.php.--Vijay