当前位置:网站首页>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
边栏推荐
- Unicode private use areas
- Intelligent shelf safety monitoring system
- PostgreSQL手动创建HikariDataSource解决报错Cannot commit when autoCommit is enabled
- Solve the problem of MSVC2017 compiler with yellow exclamation mark in kits component of QT
- 简易计算器微信小程序项目源码
- Process and concept of process
- STM32 printf problem summary semihosting microlib understanding
- Reading of false news detection papers (3): semi supervised content-based detection of misinformation via tensor embeddings
- Simulation of four way responder based on 51 single chip microcomputer
- NFC two-way communication 13.56MHz contactless reader chip -- si512 replaces pn512
猜你喜欢
TCP——滑动窗口
Dp1332e multi protocol highly integrated contactless read-write chip
[beauty of software engineering - column notes] "one question and one answer" issue 3 | 18 common software development problem-solving strategies
Markdown concise grammar manual
DC motor speed regulation system based on 51 single chip microcomputer (use of L298)
分段分页以及段页结合
DC motor control system based on DAC0832
Solve the problem of MSVC2017 compiler with yellow exclamation mark in kits component of QT
Unicode私人使用区域(Private Use Areas)
深度学习(1):银行客户流失预测
随机推荐
Charging pile charging technology new energy charging pile development
125kHz wake-up function 2.4GHz single transmitter chip-si24r2h
阿里巴巴政委体系-第一章、政委建在连队上
[academic related] why can't many domestic scholars' AI papers be reproduced?
Crawl notes
[beauty of software engineering - column notes] 28 | what is the core competitiveness of software engineers? (next)
2.4G band wireless transceiver chip si24r1 summary answer
[beauty of software engineering - column notes] 30 | make good use of source code management tools to make your collaboration more efficient
ROS common instructions
Huawei wireless device configuration uses WDS technology to deploy WLAN services
Crawl expression bag
Windows 安装 MySQL 5.7详细步骤
Temperature acquisition and control system based on WiFi
SQL 面试碰到的一个问题
[beauty of software engineering - column notes] 24 | technical debt: continue to make do with it, or overthrow it and start over?
Dp4301-sub-1g highly integrated wireless transceiver chip
Deep learning (1): prediction of bank customer loss
DAC0832 waveform generator based on 51 single chip microcomputer
ROS tutorial (Xavier)
PostgreSQL手动创建HikariDataSource解决报错Cannot commit when autoCommit is enabled