douan5151 2014-07-22 07:22
浏览 29

提供用户名和密码后,标题不会重定向到特定页面

I am using header statement to redirect my user to specific page after successful or un Successful login, but the header statement is not redirecting me to that specific page. and if i see the URL i can find (#) sign instead of the specific page

Though the same code is working on other server. I have read most of the questions and tried almost all the answer on Stackoverflow.com but all in vain. Here is my code:

if($_POST)
{
    ob_start();
    $office = $_POST["search_category"];
    $sub_category = $_POST["sub_category"];
    $password = md5($_POST["password"]);
    $query = "select * from contacts where officeid = $office and Posting = '$sub_category' and password = '$password'";
    $result = mysql_query($query) or die('Mistake in query');
    $count = mysql_num_rows($result);
    if ($count>=1)
     {
        $data = mysql_fetch_array($result);
        $_SESSION['user'] = $data['Posting']; 
        $_SESSION['semenu'] = $data['semenu'];
        $_SESSION['seid'] = $data['seid'];
        if ($_SESSION['semenu'] == 1 or $_SESSION['semenu'] == 2)
            header("location:contenrollment.php");
    else
        header("location:relogin.php");
        exit;
    ob_end_flush(); 
}?>

Instead of redirecting to any of the above two pages, I am redirected to a blank page and the blank page has the exact URL but only has (#) instead of file name. I have also checked the query, There is no mistake in it.

  • 写回答

1条回答 默认 最新

  • dousou2897 2014-07-22 07:32
    关注

    If your scripts located in root directory of site, try to use:

        header("Location: /contenrollment.php");
    

    or

        header("Location: /relogin.php");
    
    评论

报告相同问题?

悬赏问题

  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?