Model と View のような 2 つの異なるフォルダーで次のコードを使用しています。View Folder には、Login.php と Login_success.php のような 2 つの php ファイルが含まれています。コントローラ フォルダには、mysql データベース テーブル フィールド フェッチ コードが含まれています。以下のコードを実行すると、Login_success ページを表示できません。else フィールドCheck Name と passwordのみが表示されます。これらのすべてのファイルは、フォルダー index.php の外に結合されます。
ここに私のコード:
ログイン.php
<html>
<head>
<title>Login</title>
<link rel ='stylesheet' type = 'text/css' href = 'View/Design.css'>
<script>
function Validate(){
var x=document.forms["login"]["username"].value;
if (x==null || x=="")
{
alert("First name must be filled out");
return false;
}
var x=document.forms["login"]["password"].value;
if (x==null || x=="")
{
alert("Password must be filled out");
return false;
}
}
</script>
</head>
<body>
<form name = 'login' method = 'post' action = 'Controller/Controll.php' >
<fieldset>
<legend>Login</legend>
User Name :<input type = 'text' name = 'username'>
Password :<input type = 'password' name = 'password'><br><br>
<input type = 'submit' name = 'submit' value = 'submit' onsubmit = "return Validate()" >
</fieldset>
</form>
</body>
</html>
Controll.php
class Access{
function connection(){
require_once('View/Login.php');
$con = mysql_connect('localhost','root','root');
$db = mysql_select_db('Times_sheet');
$query = mysql_query('select * from Login');
$row = mysql_fetch_array($query);
if(isset($_POST['submit']))
{
if(($row['UserName']==$_POST['username']) && ($row['Password']==$_POST['password'])){
require_once("View/Login_Success.php");
}
}
else{
echo "Check User name and Password";
}
}
}
インデックス.php
require_once('Controller/Controll.php');
class login extends Access{
function getValu(){
require_once('View/Login.php');
}
}
$Obj = new login();
$Obj ->getValu();
$Obj ->connection();
正しいユーザー名とパスワードを入力すると、空のページが表示されます。どんな間違いをしたかわかりません。