0

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
  • What about replacing header("Location: home.html"); with header("Location: http://yourwebsitedomain.com/home.html");? Commented Jan 1, 2014 at 9:40
  • where is your home.html? and where is your logout.php ? is it in same path? Commented Jan 1, 2014 at 9:48
  • Yes it is in the same path. Since it is in localhost it is normally relative reference. Commented Jan 1, 2014 at 11:36

3 Answers 3

2

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
?>
Sign up to request clarification or add additional context in comments.

Comments

2

With header() you should better use a full url. Or, at least add a forward slash: header("Location: /home.html");

Comments

1

It could be that it is the reference to the page is incorrect i.e. the logout page is in a different directory to the home page use ../ to come up a directory level if it is required or use the full URL like:

 header("Location: http://www.mysite.com/home.php");

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.