好吧,我一直在尝试修复这个代码,并搜索了大约6个多小时,这让我很痛苦
我试图做的是隐藏登录表和与之相关的背景图像(即#lg#ck),并在登录表所在的位置顶部放置一个按钮,这样当点击它时,它将显示登录表
<?php
require_once( 'inc/header.inc.php' );
require_once( BX_DIRECTORY_PATH_INC . 'design.inc.php' );
require_once( BX_DIRECTORY_PATH_INC . 'db.inc.php' );
require_once( BX_DIRECTORY_PATH_INC . 'profiles.inc.php' );
check_logged();
if(!isMember()) {
echo '<body style="margin:0;">
<div style="margin:0 auto" align=center>
<form onsubmit="validateLoginForm(this); return false;" method="post" action="member.php" id="login_box_form">
<table id="ck">
<tbody>
<tr>
<td width="180">Name</td>
<td width="150">Code</td>
<td width="50"> </td>
</tr>
<tr>
<td width="180"><input style="width:180px;" name="ID" type="text"></td>
<td width="180"><input style="width:180px;"name="Password" type="password"></td>
<td><input name="LogIn" type="submit" tabindex="3" value="Login"></td>
</tr>
<tr>
<td width="180"><input type="checkbox" name="rememberMe"> Keep me logged in</td>
<td width="180"><a href="forgot.php">Forgot password?</a></td>
<td width="50"> </td>
</tr>
</tbody>
</table>
</form>
</div>
<div style="width:100%;height:20px;clear:both;"></div>
<div style="width:100%;height:600px;padding-left:40px;padding-right:40px;padding-top:20px;">';
}
else {
header("Location: index.php");
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Nox's Ark</title>
</head>
<body id="lg"> <p class="bt"></p>
</div>
</p>
<style media="screen" type="text/css">
html {
background: url(../img/bil.jpg)no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
overflow:hidden;
}
#ck {
width:450px;
border: 5px;
align:center;
cellpadding= 0px;
cellspacing= 1px;
padding-left:1100px;
padding-top:500px;
}
#lg {
background-image:url(../img/nbt.png);
background-repeat:no-repeat;
background-position: 1220px 380px;
}
.bt {
</style>
</body>
</html>
<?php
?>
这是有人建议的代码,但我甚至不知道该放在哪里。
<div id="ONE"><input type="button" value="Login" onClick="hideID('ONE');showID('TWO');" /></div>
<div id="TWO" style="display:none"><table cellspacing="0" cellpadding="0" align="center"><tr><td colspan="2"><h1>Login</h1></td></tr><tr><td>password:</td><td><input type="text" /></td></tr><tr><td>username:</td><td><input type="text" /></td></tr><tr><td colspan="2"><input type="submit" value="login" /></td></tr></table></div>
<script>
function hideID(objID){var element=(ie)?document.all(objID):document.getElementById(objID);element.style.display="none"}function showID(objID){var element=(ie)?document.all(objID):document.getElementById(objID);element.style.display="block"};
</script>
所以我放了
`<?php
require_once( 'inc/header.inc.php' );
require_once( BX_DIRECTORY_PATH_INC . 'design.inc.php' );
require_once( BX_DIRECTORY_PATH_INC . 'db.inc.php' );
require_once( BX_DIRECTORY_PATH_INC . 'profiles.inc.php' );
check_logged();
if(!isMember()) {
echo '<body style="margin:0;">
<div style="margin:0 auto" align=center>
<form onsubmit="validateLoginForm(this); return false;" method="post" action="member.php" id="login_box_form">
<table id="ck">
<tbody>
<tr>
<td width="180">Name</td>
<td width="150">Code</td>
<td width="50"> </td>
</tr>
<tr>
<td width="180"><input style="width:180px;" name="ID" type="text"></td>
<td width="180"><input style="width:180px;"name="Password" type="password"></td>
<td><input name="LogIn" type="submit" tabindex="3" value="Login"></td>
</tr>
<tr>
<td width="180"><input type="checkbox" name="rememberMe"> Keep me logged in</td>
<td width="180"><a href="forgot.php">Forgot password?</a></td>
<td width="50"> </td>
</tr>
</tbody>
</table>
</form>
</div>
<div style="width:100%;height:20px;clear:both;"></div>
<div style="width:100%;height:600px;padding-left:40px;padding-right:40px;padding-top:20px;">';
}
else {
header("Location: index.php");
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Nox's Ark</title><div id="ONE"><input type="button" value="Login" onClick="hideID('ONE');showID('TWO');" /></div>
<div id="TWO" style="display:none"><table cellspacing="0" cellpadding="0" align="center"><tr><td colspan="2"><h1>Login</h1></td></tr><tr><td>password:</td><td><input type="text" /></td></tr><tr><td>username:</td><td><input type="text" /></td></tr><tr><td colspan="2"><input type="submit" value="login" /></td></tr></table></div><script>function hideID(objID) {
var element = (ie) ? document.all(objID) : document.getElementById(objID);
element.style.display = "none";
}
function showID(objID) {
var element = (ie) ? document.all(objID) : document.getElementById(objID);
element.style.display = "block";
}</script>
</head>
<body id="lg"> <p class="bt"></p>
</div>
</p>
<style media="screen" type="text/css">
html {
background: url(../img/bil.jpg)no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
overflow:hidden;
}
#ck {
width:450px;
border: 5px;
align:center;
cellpadding= 0px;
cellspacing= 1px;
padding-left:1100px;
padding-top:500px;
}
#lg {
background-image:url(../img/nbt.png);
background-repeat:no-repeat;
background-position: 1220px 380px;
}
.bt {
</style>
</body>
</html>
<?php
?>`
这只在左侧显示了一个登录按钮,在右侧显示了以前的登录表(我试图隐藏它)。单击左侧的登录按钮后不会执行任何操作。。我真的如果你们能帮我做这件事,我很感激,我甚至认为我看教程都做不到。。救我;_;
我要做的是:
<div id="ONE"><input type="button" value="Login" onClick="hideID('ONE');showID('TWO');" /></div>
<div id="TWO" style="display:none"><table cellspacing="0" cellpadding="0" align="center"><tr><td colspan="2"><h1>Login</h1></td></tr><tr><td>password:</td><td><input type="text" /></td></tr><tr><td>username:</td><td><input type="text" /></td></tr><tr><td colspan="2"><input type="submit" value="login" /></td></tr></table></div>
使用JavaScript:
function hideID(objID) {
var element = (ie) ? document.all(objID) : document.getElementById(objID);
element.style.display = "none";
}
function showID(objID) {
var element = (ie) ? document.all(objID) : document.getElementById(objID);
element.style.display = "block";
}
希望它能有所帮助!