首先看一下成果图
登录界面源码
<?php
@$username = $_REQUEST['username'];
@$password = $_REQUEST['password'];
$con = mysqli_connect('localhost','root','root','mysql');
$sql = "select *from mydb where username='$username'and password='$password'";
$result = mysqli_query($con,$sql);
$a = mysqli_fetch_array($result);
if ($a['username'] == $username &$a['password'] == $password & $username!=null& $password!=null )
{
echo "登陆成功";
}
else
{
echo'登录失败';
}
<meta charset="UTF-8">
<form action="dl.php" mothod="GET">
帐号:<input type="text" name="username"/><br>
密码:<input type="text" name="password"/><br>
<input type="submit" value="登录"/>
<input type="submit" value="注册"/>
</form>
注册界面源码
<?php
@$username = $_REQUEST[‘username’];
@$password = $_REQUEST[‘password’];
$con = mysqli_connect(‘localhost’,’root’,’root’,’mysql’);
$sql = “insert into mydb value(‘$username’,’$password’)”;
if ($username==null&$password==null)
{
echo ‘请填写正确的用户名或密码!’;
}
else
{
echo ‘<pre>‘;
echo’注册成功!’;
echo ‘<pre>‘;
echo $username;
echo ‘<pre>‘;
echo $password;
echo ‘<pre>‘;
}
?>
```html
<meta charset="UTF-8">
<form action="zc.php" mothod="GET">
帐号:<input type="text" name="username"/><br><br>
密码:<input type="text" name="password"/><br><br>
<input type="submit" value="注册" name="zhuce">
</form>
新手上路多多指教。