当前位置:网站首页>Day6: using PHP to write landing pages
Day6: using PHP to write landing pages
2022-07-29 08:20:00 【EdmunDJK】
DAY6: utilize PHP Write landing page
Here the code is released directly , Too lazy , I won't explain it in detail
Create several here php file 
1、 Code display
The file with blue background in the figure , Here release the code (login.php、signup.php、conn.php)
1.1、login.php
<?php
error_reporting(0);
session_start();
$postUsername =isset($_POST['username'])? $_POST['username'] : '';// user name
$postpassword =isset($_POST['password'])? $_POST['password'] : '';// password
$conn = mysqli_connect("127.0.0.1","root","admin123", "regist") or die(" Database connection error !");// Corresponding database address user name And password
$sql ="SELECT username,password1 FROM users WHERE username ='$postUsername'";
$query =mysqli_query($conn,$sql);
$row =mysqli_fetch_array($query,MYSQLI_ASSOC);
$username =isset($row['username'])? $row['username'] : '';
$password =isset($row['password1'])? $row['password1'] : '';
$_SESSION["username"]=$postUsername;
if(isset($_POST['login']))
{
if($username ==$postUsername && $password==$postpassword)
{
echo"<script>alert(' Login successful ');window.location ='1.php'</script>";
}
else
{
echo"<script>alert(' Wrong user name or password !');history.go(-1)</script>";
}
}
$user;
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title> Landing page </title>
</head>
<body>
<h2> Landing page </h2>
<form action ="" method = "post" name ="myform" ousubmit ="return Checked();">
<table>
<tr>
<td> user name :</td>
<td><input type="text" name="username"></td>
</tr>
<tr>
<td> password :</td>
<td><input type="password" name="password"></td>
</tr>
<tr>
<td><input type="submit" name="login" value=" Sign in "></td>
<td><a href ="signup.php"> register </a></td>
</tr>
<tr>
<td><a href="7.html"> Back to the home page </a></td>
</tr>
</table>
</form>
</body>
</html>
Because there are some problems written before , Debugging will include() Function comments , So this file is not used include(conn.php);
1.2、signup.php:
<?php
session_start();
include("conn.php");// Connect to database
$username =isset($_POST['username'])? $_POST['username'] : '';// user name
$password2 =isset($_POST['password2'])? $_POST['password2'] : '';// password
$password1 =isset($_POST['password1'])? $_POST['password1'] : '';
if(isset($_POST['signup']))
{
if($password2==$password1)
{
$sql ="INSERT INTO users VALUE('$username','$password2');";
mysqli_query($conn,$sql);
echo "<script>alert(' Registered successfully ');window.location ='login.php';</script>";
}
else
{
echo "<script>alert(' The two passwords don't match !');window.location ='login.php';</script>";
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<h2> Registration page </h2>
<form action ="" method = "post" name ="myform" ousubmit ="return Checked();">
<table>
<tr>
<td> user name :</td>
<td><input type="text" name="username"></td>
</tr>
<tr>
<td> password :</td>
<td><input type="password" name="password1"></td>
</tr>
<tr>
<td> Confirm the password :</td>
<td><input type="password" name="password2"></td>
</tr>
<tr>
<td><input type="submit" name="signup" value=" register "></td>
<td><a href ="login.php"> Sign in </a></td>
</tr>
<tr>
<td><a href="7.html"> Back to the home page </a></td>
</tr>
</table>
</form>
</body>
</html>
1.3、conn.php
<?php
$conn = mysqli_connect("127.0.0.1","root","admin123") or die(" Database connection error !");// Corresponding database address user name And password
$selected = mysqli_select_db($conn,"regist");
?>
Key points have been noted , Some important functions can be searched in the rookie tutorial
2、 Show pictures
Login interface

The registration screen

Back to the home page 
边栏推荐
- STM32 detection signal frequency
- Official tutorial redshift 01 basic theoretical knowledge and basic characteristics learning
- Qt/pyqt window type and window flag
- Reading of false news detection papers (3): semi supervised content-based detection of misinformation via tensor embeddings
- What constitutes the smart charging pile system?
- Beautiful girls
- Internet worm
- Time function in MySQL
- AES 双向加密解密工具
- 数仓分层设计及数据同步问题,,220728,,,,
猜你喜欢

Intelligent shelf safety monitoring system

Some tools, plug-ins and software links are shared with you~

谷歌浏览器免跨域配置

Proteus simulation based on msp430f2491 (realize water lamp)

STM32 detection signal frequency

Hal library learning notes - 8 concept of serial communication

Simple calculator wechat applet project source code

Week 1 task deep learning and pytorch Foundation

sql判断语句的编写

Detailed steps of installing MySQL 5.7 for windows
随机推荐
Back up Google or other browser plug-ins
Inclination sensor accuracy calibration test
Proteus simulation based on 51 MCU ADC0808
Smart energy management system solution
简易计算器微信小程序项目源码
Simplefoc parameter adjustment 3-pid parameter setting strategy
Lora opens a new era of Internet of things -asr6500s, asr6501/6502, asr6505, asr6601
Domestic application of ft232 replacing gp232rl usb-rs232 converter chip
Tensorboard use
DC motor speed regulation system based on 51 single chip microcomputer (use of L298)
centos7/8命令行安装Oracle11g
Application of explosion-proof inclination sensor in safe operation of LNG
torch.nn.functional.one_ hot()
Alibaba political commissar system - Chapter 4: political commissars are built on companies
Segment paging and segment page combination
Dp4301-sub-1g highly integrated wireless transceiver chip
Mysql rownum 实现
torch.Tensor和torch.tensor的区别
Charging pile charging technology new energy charging pile development
Official tutorial redshift 01 basic theoretical knowledge and basic characteristics learning