直播源码网站,新用户登录时的注册页面和登录页面实现的相关代码
<?php
header("Content-type:text/html;charset=utf-8");
$link = mysqli_connect('localhost','root','');
mysqli_set_charset($link,'utf8'); //设定字符集
mysqli_select_db($link,'login');
$name=$_POST['Username'];
$pwd=$_POST['Password'];
$rpwd=$_POST['Re_Password'];
$code = $_POST['Code'];
if (!$link) {
die("连接失败: " .mysqli_connect_error());
}
else if(strlen($pwd) < 5||strlen($pwd)>10){
echo"<script>alert('你的密码需要5~10位');window.location.href='注册1.php'</script>";
exit;
}
else if($rpwd != $pwd){
echo"<script>alert('你输入的两次密码不一致,请重新输入');window.location.href='注册1.php'</script>";
exit;
}
else{
$sql="insert into user(name, password)values('$name','$pwd')";
}
// 调用mysqli的query方法
if(!(mysqli_query($link,$sql))){
echo "<script>alert('注册失败');window.location.href='注册1.php'</script>";
}else{
echo "<script>alert('注册成功');window.location.href='登录1.php'</script>";
}
?>
```<?php
header("Content-type:text/html;charset=utf-8");
$link = mysqli_connect('localhost','root','');
mysqli_set_charset($link,'utf8'); //设定字符集
mysqli_select_db($link,'login');
$name=$_POST['Username'];
$pwd=$_POST['Password'];
$rpwd=$_POST['Re_Password'];
$code = $_POST['Code'];
if (!$link) {
die("连接失败: " .mysqli_connect_error());
}
else if(strlen($pwd) < 5||strlen($pwd)>10){
echo"<script>alert('你的密码需要5~10位');window.location.href='注册1.php'</script>";
exit;
}
else if($rpwd != $pwd){
echo"<script>alert('你输入的两次密码不一致,请重新输入');window.location.href='注册1.php'</script>";
exit;
}
else{
$sql="insert into user(name, password)values('$name','$pwd')";
}
// 调用mysqli的query方法
if(!(mysqli_query($link,$sql))){
echo "<script>alert('注册失败');window.location.href='注册1.php'</script>";
}else{
echo "<script>alert('注册成功');window.location.href='登录1.php'</script>";
}
?>
<?php
header("Content-type:text/html;charset=utf-8");
$link = mysqli_connect('localhost','root','');
mysqli_set_charset($link,'utf8'); //设定字符集
mysqli_select_db($link,'login');
$name=$_POST['Username'];
$pwd=$_POST['Password'];
if (!$link) {
die("连接失败: " .mysqli_connect_error());
}
//在数据库中查看是否存在用户名及密码
$sql = "select name,password from user where name='$name' and password='$pwd'";
$result=mysqli_query($link, $sql);
$row = mysqli_fetch_array($result,MYSQLI_BOTH);
$number = mysqli_num_rows($result);
if($number){
echo "<script>alert('登录成功');location='登录1.php'</script>";
}
else{
echo "<script>alert('您输入的用户名不存在');location='登录1.php'</script>";
exit;
}
?>
以上就是直播源码网站,新用户登录时的注册页面和登录页面实现的相关代码, 更多内容欢迎关注之后的文章
- 海报