开发者

PHP file not being run

I have a PHP file that I'm trying to run. However, my web browsers act like it doesn't exist. For example, Firefox tries to open the PHP file Chrome says This webpage is not available. Error 324 (net::ERR_EMPTY_RESPONSE): Unknown error. Internet Explorer says Internet Explorer cannot display the webpage

I'm trying to access this php file through a form submission ie action="login.php" I've also tried accessing this file by localhost/login.php and I get the same results.

I know php is configured properly because all my other php files run fine just this one is giving me problems. For example, localhost/home.php works

btw, I do not have this problem when I tried to load the php file (it works properly) on another computer I have so I know the php file compiles properly.

Anyone have any ideas? I tried deleting all my caches (Firefox, IE, Chrome, Twig) but nothing works.

Thanks

edit: here are the php files i'm talking about login.php

    function generate_salt($username) 
    {  
        // Create a SHA1 hash  
        $salt = sha1('~'.$username.'~'.microtime(TRUE).'~');  

        // Limit to random 10 characters in the hash  
        $salt = substr($salt, rand(0,30), 10);  

        return $salt;  
    }

    function hash_password($password, $salt) 
    {  
        return 开发者_开发百科sha1('~'.$password.'~'.$salt.'~');  
    }  

    function valid_password($password, $hash, $salt) 
    {  
        return hash_password($password, $salt) == $hash;  
    }
    $loginStatus = false;

    //echo $_POST['username'] . " ";
    //echo $_POST['password'] . "\n";

    $username = $_POST['username'];
    $password = $_POST['password'];


    $db = new dbHelper(); 


    $user = $db->getUser($username);


    if(!$user)
    {
        $loginStatus = false;
    }
    else
    {
        $loginStatus = valid_password($password, $user->getPassword(), $user->getSalt());
    }

    if($loginStatus)
    {
        $db->createSession($user);
    }

    if($loginStatus)
    {
        echo "Login Successful";
        echo '<META HTTP-EQUIV="Refresh" Content="0;URL=index.php"/>';
    }
    else
    {
        echo "Incorrect Username or Password";
        echo '<META HTTP-EQUIV="Refresh" Content="0;URL=index.php#ui-tabs-3"/>';
    }
    //echo json_encode($loginStatus);
?>

home.php

<?php
    //require_once './library.php';
    require_once './twigLoader.php';
    require_once './loginStatus.php';

    $template = $twig->loadTemplate('home.html');

    $nameArr = array("hi", "bye");

    echo $template->render(array('loginStatus' => $loginStatus,
                                'nameArr' => $nameArr));
?>


Check Apache's error_log or the PHP log file, if any. Most likely there's an early error in the script. You can also try activating the display_errors and display_startup_errors options in your php.ini (I'm assuming this is a development installation).


Download latest version of xampp.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜