douyan2002 2017-01-18 17:54
浏览 55
已采纳

将某些用户重定向到不同的页面(PHP)

I am trying to redirect registered users who's email address contains a certain string.

example email 1 -> 12345@email.com
example email 2 -> 12345.abc@email.com

I want to separate emails containing .abc@email.com and send them to a separate page using a header redirect. This is intended in signing in a user with an email containing .abc@ to an administration page.

Currently all users are being redirected to the same page regardless of the email address.

Example snippet code below. This is my first time asking a question, I hope I have supplied enough information.

$_SESSION["user_id"] = $row[0];
$_SESSION["fname"] = $row[1];
if ($email==".abc@email.com")
{
    header('Location:home.php');
}
else
    header ('Location:home2.php');
}
  • 写回答

2条回答 默认 最新

  • dsfsda121545 2017-01-18 18:19
    关注

    You need to cut off your email string, if you want to compare only the last part.

    $cmp = ".abc@email.com";
    if (substr($email, -strlen($cmp)) == $cmp)
    {
        header('Location:home.php');
    }
    else
        header ('Location:home2.php');
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?