【问题标题】:Redirect to different assigned pages if username and password correct如果用户名和密码正确,则重定向到不同的分配页面
【发布时间】:2017-09-04 15:55:43
【问题描述】:

我需要有关 PHP 错误的帮助,我想在这里使用表单登录输入重定向到不同的页面,因为我不知道如何制作管理后端以通过数据库将用户重定向到不同的页面,这里是我的PHP

脚本

// 重定向到不同的页面

<?php $userid = $_POST['userid'];
    $userpass = $_POST['password']; 

    if (strcmp($userid, "3495062250") && strcmp($password, "12smith00") ) { 
    header('location: account-dashboard/client_349506_2243/index.html');

   } else{ header('location: error.html'); } ?>

【问题讨论】:

标签: php redirect http-redirect


【解决方案1】:

请检查以下代码。

你做错了。

  • 在 if 条件下,您使用了 $password 而不是 $userpass
  • 您可以在PHP 中使用equal operator 简单地比较字符串

    $userid = $_POST['userid'];
    $userpass = $_POST['password'];
    if ($userid = "3495062250" && $userpass == "12smith00") {
        header('location: account-dashboard/client_349506_2243/index.html');
    } else {
        header('location: error.html');
    }
    

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-05-06
    • 2011-09-15
    • 1970-01-01
    • 1970-01-01
    • 2021-10-15
    • 1970-01-01
    • 2020-08-14
    相关资源
    最近更新 更多