我有两个 php 页面。index.php 和functions.php。在 index.php 中,我从 functions.php 调用登录和更改密码函数。我的问题是,当我单击登录时,我的登录表单将与更改密码表单一起显示。我只想在单击登录时显示更改密码表单。请帮忙!!
这是我的代码:index.php
<?php session_start(); ?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title> Login to the site</title>
</head>
<body>
<form action="index.php?act=login" method="post" id= "user_login" >
<center>
<table>
<tr>
<td>User Login</td>
<td><a href="index.php?act=login" >Click Here</a></td>
</tr>
<tr>
<td>Forgot Password?</td>
<td><a href="index.php?act=forgotpassword">Click Here</a></td>
</tr>
</center>
<table>
</form>
<?php
include "functions.php";
$action_type = $_GET["act"];
$form_name = $_GET["name"];
if ($action_type == "login")
{
return login();
}
elseif ($action_type == "forgotpassword")
{
return forgotpassword();
}
elseif ($action_type == "changepassword")
{
return changepassword();
}
?>
</body>
</html>
函数.php:
function login()
{
echo' <script type="text/javascript">
function showhide() {
var form = document.getElementById("login");
if (form.style.visibility == "visible") {
form.style.visibility = "hidden";
}
}
</script>
<form action="index.php?act=login" method="post" id="login" >
<center>
<table cellpadding="2" cellspacing="2" border="0">
<tr>
<td width="30%" align="right">Username</td>
<td width="70%"><input type="text" name="user" id="text_user"/></td>
</tr>
<tr>
<td align="right">Password</td>
<td><input type="password" name="pass" id="text_pass" /></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" value="login" name="submit" onsubmit="showhide()" /></td>
</tr>
</center>
</table>
</form> </body></html>';
// login code goes here
}
function changepassword()
{
echo'<form action ="index.php?act=changepassword" method="post" >
<table cellpadding="2" cellspacing="2" border="0">
<tr>
<td>Existing Password</td>
<td><input type="password" value="" name="pass" id="text_pass" /></td>
</tr>
<tr>
<td>New Password</td>
<td><input type="password" value="" name="cpass" id="text_cpass"/></td>
</tr>
<tr>
<td>Retype Password</td>
<td><input type="password" value="" name="crepass" id="text_crepass" /></td>
</tr>
<tr>
<td><input type="submit" value="change" name="submit" /></td>
</tr>
</table>
<tr align = "left"> <td><br><a href="index.php?act=logout">LogOut</a></br> </td></tr>
</form>';
// changepassword code goes here
}
?>