Implementation case of php registration and login interface

墨辰丷
Release: 2023-03-28 16:18:01
Original
3329 people have browsed it

This article mainly introduces the implementation case of PHP registration and login interface. Interested friends can refer to it. I hope it will be helpful to everyone.

At first I thought the two functions of registration and login on a website were magical. Later, I did some research and found that the truth is actually very simple. Let’s take a look at how to implement it. . . .

I created several files on my computer:

login.html (login page)

register.html (Registration page)

success.html (Login success redirect page)

return.html (Registration success page )

login.php

register.php

Login interface and registration interface and success.html are combined There is no

, everything is just some html tags as follows:




登录界面

账号:

密码: 没有账号,注册
Copy after login




会员注册

账 户:

密 码:

密码确认:
Copy after login

return.html is the page that appears after successful registration. There is a js code in it that is used to return to the login interface regularly




无标题文档

注册成功!
5秒后返回登录界面
你也可以直接点击回到登录页面
Copy after login

register.php It is the background page corresponding to the registration page

"."window.alert"."("."\""."请填写完成!"."\"".")".";"."";
          echo"";    
          exit;
        }
        if($password1==$password2)//确认密码是否正确
        {
        $str="select count(*) from register where username="."'"."$name"."'";
        $result=mysql_query($str,$link);
        $pass=mysql_fetch_row($result);
        $pa=$pass[0];
        if($pa==1)//判断数据库表中是否已存在该用户名
        {
        
        echo"";
        echo"";   
        exit; 
        }
        
        
        $sql="insert into register values("."\""."$name"."\"".","."\""."$password1"."\"".")";//将注册信息插入数据库表中
        //echo"$sql";
        mysql_query($sql,$link);
        mysql_query('SET NAMES UTF8');
        $close=mysql_close($link);
        if($close)
        {
          //echo"数据库关闭";
          //echo"注册成功!";
          echo"";    
        }
        }
        else
        {
          echo"";
          echo"";    
        }
      }
    }
  }
?>
Copy after login

login.php login interface corresponding to the background file

"."window.alert"."("."\""."请填写正确的信息!"."\"".")".";"."";
        echo"";
        exit;
      }
      $str="select password from register where username="."'"."$name"."'";
      mysql_query('SET NAMES UTF8');20       $result=mysql_query($str,$link);
      $pass=mysql_fetch_row($result);
      $pa=$pass[0];
      if($pa==$password)//判断密码与注册时密码是否一致
      {
        echo"登录成功!";
        echo"";
      }
      {  
        echo"";
        echo"";
      }
    }
    
  }
}
?>
Copy after login

I still have a lot to improve when I have nothing to do. You are welcome to ask questions and discuss and provide easier methods!

The above is the entire content of this article, I hope it will be helpful to everyone's study.


Related recommendations:

phpWhat are the steps to use redis long connection

phpDetailed explanation of application containerization and deployment

##phpHow to implement data export

phpSimple winning algorithm example

##

The above is the detailed content of Implementation case of php registration and login interface. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact [email protected]
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!