下面是一个简单的PHP代码示例,实现了登录和注册功能。
首先,创建一个名为index.php
的文件,用于显示登录和注册表单:
<!DOCTYPE html>
<html>
<head>
<title>登录和注册</title>
</head>
<body>
<h2>登录</h2>
<form method="post" action="login.php">
<label>用户名:</label>
<input type="text" name="username" required><br><br>
<label>密码:</label>
<input type="password" name="password" required><br><br>
<input type="submit" value="登录">
</form>
<h2>注册</h2>
<form method="post" action="register.php">
<label>用户名:</label>
<input type="text