Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/232.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 会话在登录页面不工作?_Javascript_Php_Mysql - Fatal编程技术网

Javascript 会话在登录页面不工作?

Javascript 会话在登录页面不工作?,javascript,php,mysql,Javascript,Php,Mysql,我只是在我的HP服务器上构建Centos 6.4,我使用PHP5.3.3、Apache 2.2.15、Mysql 5.1.69。 当我想登录总是失败时,源代码如下: index.php <? include "functions.php"; start_session(); session_destroy(); start_session(); ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//E

我只是在我的HP服务器上构建Centos 6.4,我使用PHP5.3.3、Apache 2.2.15、Mysql 5.1.69。 当我想登录总是失败时,源代码如下:

index.php
    <?
include "functions.php";
start_session();
session_destroy();
start_session();
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
    <title>Please Login First</title>
    <link href="Tampilan/css/bootstrap.min.css" rel="stylesheet" media="screen">
        <link href="Tampilan/css/validationEngine.jquery.css" rel="stylesheet" type="text/css" />
        <script type="text/javascript" src="Tampilan/js/jquery-1.9.1.min.js"></script>
        <script type="text/javascript" src="Tampilan/js/jquery.validationEngine.js" ></script>
        <script type="text/javascript" src="Tampilan/js/jquery.validationEngine-en.js" ></script>
        <style type="text/css">
            .myTableStyle {
                position: absolute;
                top: 45%;
                left: 37%;
            }
            #full-screen-background-image {
                z-index: -999;
                width: 100%;
                height: auto;
                position: fixed;
                top: 0;
                left: 0;
            }

            #wrapper {
                position: relative;
                width: 800px;
                min-height: 400px;
                margin: 100px auto;
                color: #333;
            }
            .overlay-text {
                position: absolute;
                top: 20px;
                left: 225px;
                font-size: 38.5px;
                font-weight: bold;
                color: #ddd;
                font-family: "Palatino Linotype", "Book Antiqua", Palatino, serif;
            }
        </style>
    <script src="content/md5.js"></script>
    <script>
    function cek()
    {
    if(!document.form1.username.value)
        {
        document.form1.username.focus();
        window.alert("Please Fill In The Username");
        }
    else if(!document.form1.password.value)
        {
        document.form1.password.focus();
        window.alert("Please Fill In The Password");
        }
    else {
        document.form2.username.value=document.form1.username.value;
        document.form2.password.value=calcMD5(document.form1.password.value);
        document.form2.submit();
        }   
    }
    </script>
    <link href="style.css" rel="stylesheet" type="text/css">
    <link href="bootstrap.min.css" rel="stylesheet" type="text/css">
    <noscript>
        <div class="pagetitle">This page cannot be loaded properly because your browser has been set to deny the usage of Javascript. Please enable the Javascript support at your browser in order to continue</div>
        <meta http-equiv="Refresh" content="0;noscript.php"/>
    </noscript>
</head>
<div class="all-page">
        <div class="page-header">
            <!--<img alt="image" src="Tampilan/img/Stema1.jpg" style="height: 300px;width: 100%;z-index: -1;"/>!-->&nbsp;
            <p class="overlay-text">
                SIS Admission
            </p>
            <body onload="document.form1.username.focus()">
                <form name="form1" action="javascript:cek()">
                    <table border="0" cellspacing="0" cellpadding="0" width="100%" height="100%">
                        <tr>
                                <td width="100%" valign="middle" align="center">
                                    <table border="0" align="center" width="300" cellpadding="0" cellspacing="0">
                                        <tr>
                                            <td align="center" colspan="2" height="50"><div class="medTitle">Please Login</div></td>
                                        </tr>
                                        <tr>
                                            <td align="center" width="120" height="30"><div class="smallTitle">Username </div></td>
                                            <td align="left"><input type="text" name="username" class="input"/></td>
                                        </tr>
                                        <tr>
                                            <td align="center" height="30"><div class="smallTitle">Password </div></td>
                                            <td align="left"><input type="password" class="input" name="password"/></td>
                                        </tr>
                                        <tr>
                                            <td align="center" colspan="2" height="40"><input type="submit" class="button" value="Login"/></td>
                                        </tr>
                                    </table>
                                </td>
                            </tr>

                        </table>
                        </form>
                        <form name="form2" action="login.php" method="post">
                            <input type="hidden" name="username"/>
                            <input type="hidden" name="password"/>
                            <input type="hidden" name="sess" value="<?=session_id();?>"/>
                        </form>
                <div class="well navbar navbar-fixed-bottom">
            <center>
                Copyright &copy; 2013 <a href="http://www.stellamaris.co.id/" target="_blank">Saint John's Catholic School</a> Developed by IT Department Of Saint John's Catholic School<a href="javascript:pergiKe('credit')"></a>. All Rights Reserved.
            </center>
    </div>
</body>
</html>



login.php

<?
include "functions.php";
if(!isset($_POST['username'])||!isset($_POST['password'])||!isset($_POST['sess'])){
?>
<script>
alert("Silahkan masukan username/password anda");
location.href="index.php";
</script>
<?

}
else
{
    session_start();
    $session_id=$_POST['sess'];
    if($session_id!=session_id()){
        ?>
        <script>
        alert("Untuk dapat menggunakan website ini, browser anda haruslah menerima cookie yang diberikan");
        location.href="index.php";
        </script>
        <?
    }
    else{
        $username=$_POST['username'];
        $password=$_POST['password'];
        connect_local();
        $pola_password="^[a-zA-Z0-9]{1,}$";
        $pola_username="^[a-zA-Z0-9_]{1,}$";
        if(!ereg($pola_username,$username)){
            ?>
            <script>
            alert("Silahkan masukan username");
            location.href="index.php";
            </script>
            <?
        }
        else if(!ereg($pola_password,$password)){
            ?>
            <script>
            alert("Silahkan masukan password");
            location.href="index.php";
            </script>
            <?
        }
        else{
            $query="select * from ms_user where username='$username' and password='$password'";
            $result=mysql_query($query);
            if(mysql_num_rows($result)>1) {
                ?>
                <script>
                alert("Username/password tidak terdaftar");
                location.href="index.php";
                </script>
                <?
            }
            else if(mysql_num_rows($result)==1){
                 $hasil=mysql_fetch_array($result);
                 if($hasil['status']==0){
                ?>
                    <script>
                    alert("Username/password tidak terdaftar");
                    location.href="index.php";
                    </script>
                    <?
                 }
                 else{
                     $username=$hasil['username'];
                     $id_ms_user=$hasil['id_ms_user'];
                     $status=$hasil['status'];
                     $_SESSION['ses_username']=$username;
                     $_SESSION['ses_user_id']=$id_ms_user;
                     $_SESSION['ses_access_level']=$status;
                     header("location:main.php");
                 }
            }
            else {
            ?>
                <script>
                alert("Username/password tidak terdaftar");
                location.href="index.php";
                </script>
            <?
            }
        }
    }
}
?>
index.php
请先登录
.myTableStyle{
位置:绝对位置;
最高:45%;
左:37%;
}
#全屏背景图像{
z指数:-999;
宽度:100%;
高度:自动;
位置:固定;
排名:0;
左:0;
}
#包装纸{
位置:相对位置;
宽度:800px;
最小高度:400px;
保证金:100像素自动;
颜色:#333;
}
.叠加文本{
位置:绝对位置;
顶部:20px;
左:225px;
字号:38.5px;
字体大小:粗体;
颜色:#ddd;
字体系列:“Palatino Linotype”,“Book Antika”,Palatino,衬线;
}
函数cek()
{
如果(!document.form1.username.value)
{
document.form1.username.focus();
window.alert(“请填写用户名”);
}
否则如果(!document.form1.password.value)
{
document.form1.password.focus();
窗口提示(“请填写密码”);
}
否则{
document.form2.username.value=document.form1.username.value;
document.form2.password.value=calcMD5(document.form1.password.value);
文件。表格2。提交();
}   
}
无法正确加载此页面,因为您的浏览器已设置为拒绝使用Javascript。请在浏览器上启用Javascript支持以继续

SIS入院

请登录 用户名 暗语 替换

start_session();
借-

它的会话\u开始()不是
start\u会话()
也可以在index.php中使用

<?
    include "functions.php";
    if(!isset($_SESSION))
    {
        session_start();
    }
    if($_SESSION['ses_username'] == '')
    {
        session_destroy();
    }
?>

你在用什么代码

start_session();
session_destroy();
start_session();
拆下所有这些部件,并将其更换为

    session_start();
    if($_SESSION['ses_username'] == "")
    {
        session_destroy();
    }

不工作意味着什么?什么不起作用?您是否收到任何错误?您必须在页面顶部使用
session\u start()
,并且只能使用一次。您为什么要多次使用它?/我登录时总是显示此警报代码。?>警报(“用户名/密码tidak terdaftar”);location.href=“index.php”;替换start_session()时仍然不想工作;使用session_start();在register globals和会话cookies中是否有php.ini配置的链接?我已经将您的代码放入了我的代码中,但仍然无法登录。。。安全检查总是在说:您的用户名和密码错误时激活。我已经仔细检查了用户名和密码是否正确。我已经将您的代码放入我的代码中,但仍然无法登录。。。安全检查总是在说:您的用户名和密码错误时激活。我仔细检查了用户名和密码是否正确。
    session_start();
    if($_SESSION['ses_username'] == "")
    {
        session_destroy();
    }