dongyanghan0556 2014-01-01 01:37
浏览 32
已采纳

PHP:退出问题?

Dear all my brothers and sisters. Recently I have create a project web site. Everthing works fine, but the problem is when I click log out the following error page appears. Also I have looks for the same problem in stack overflow and then I tried, but my issue is not fixed yet.

Object not found!

The requested URL was not found on this server. The link on the referring page seems to be wrong or outdated. Please inform the author of that page about the error.

If you think this is a server error, please contact the webmaster.
Error 404
localhost
Apache/2.4.7 (Win32) OpenSSL/1.0.1e PHP/5.5.6 

             **My PHP scripts for check LOGIN.PHP is:**

<?php  


    session_start();    


    $host="localhost"; // Host name

    $username="root"; // Mysql username

    $password=""; // Mysql password

    $db_name="fb"; // Database name

    $tbl_name="users"; // Table name    


    // Connect to server and select databse.

    mysql_connect("$host", "$username", "$password")or die("cannot connect");

    mysql_select_db("$db_name")or die("cannot select DB");    


    // username and password sent from form

    $name=$_POST['email'];

    $password=$_POST['pwd'];

//select data from database    


    $sql="SELECT * FROM $tbl_name WHERE usermail='$name' && userpasswd='$password'";

    $result=mysql_query($sql);    


    // Mysql_num_row is counting table row

    $count=mysql_num_rows($result);    


    // If result matched $myusername and $mypassword, table row must be 1 row    


    if($count==1){

        // Register $myusername, $mypassword and redirect to file "search.php"

        //session_register("$name");

        //session_register("$password");

        $_SESSION['usermail']= $name;

        $_SESSION['userpasswd']=$password;

        header("location:home.php");    
    }

    else {

        $msg = "Wrong Username or Password. Please retry";

        header("location:ErrorPage.html");      

    }

?>
                  **PHP script for HOME.HTML**
<?php

session_start();

require("checklogged.php");

?>
                  **My LOGOUT.PHP script is:**

<?php
session_start();
$_SESSION['usermail'] ='$name';
$_SESSION['userpasswd']='$password';
session_unset();
session_destroy();
header("Location: login.html");//This is my initial login page
?>

展开全部

  • 写回答

3条回答 默认 最新

  • dourong8495 2014-01-01 01:41
    关注

    You are getting a 404 error , which means there is no such home.html file which you have put it in the logout.php file. Try changing that to index.php or login.php (if you have that)

    Like this...

    session_unset();
    session_destroy();
    header("Location: index.php"); //<-- Change here
    ?>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)
编辑
预览

报告相同问题?

悬赏问题

  • ¥15 下载honeyd时报错 configure: error: you need to instal a more recent version of libdnet
  • ¥15 距离软磁铁一定距离的磁感应强度大小怎么求
  • ¥15 霍尔传感器hmc5883l的xyz轴输出和该点的磁感应强度大小的关系是什么
  • ¥15 vscode开发micropython,import模块出现异常
  • ¥20 Excel数据自动录入表单并提交
  • ¥30 silcavo仿真,30分钟,只需要代码
  • ¥15 FastReport 怎么实现打印后马上关闭打印预览窗口
  • ¥15 利用3支股票数据估计其均值和方差的95%置信区间。
  • ¥15 微信小程序运行一项功能时,弹出未知错误弹框,检查代码没有问题
  • ¥15 ATAC测序生成self-pseudo replicates之前是否要进行去线粒体reads
手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部