当前位置:网站首页>037 PHP login, registration, message, personal Center Design
037 PHP login, registration, message, personal Center Design
2022-07-06 01:13:00 【Prison plan progress 50%】
List of articles
One : Structure catalog




Two : Source content
C:\phpStudy\WWW\PHP\xnfhbbs\index.php
<?php
include "./inc/dblink.inc.php";
?>
<html>
<head>
<meta charset="utf-8">
<title> home page -- In a flash </title>
</head>
<body>
<h1> In a flash BBS Forum </h1>
<?php
if(isset($_COOKIE['name'])){
echo " Welcome ,<a href='./member/'>".$_COOKIE['name']."</a>";
}else{
echo "<a href='./member'> Membership Center </a>";
}
echo "| <a href='./addCont.php'> Welcome to leave a message </a>";
echo "<hr />";
$sql="select * from messages";
if($results=mysqli_query($link,$sql)){
if(mysqli_num_rows($results)>0){
echo "<table border = 2>";
echo "<tr><td>ID</td><td>TITLE</td><td>AUTHOR</td></tr>";
while($result=mysqli_fetch_assoc($results)){
//var_dump($result);
echo "<tr><td>{
$result['id']}</td><td><a href='showmsg.php?id= {
$result['id']}' target='_blank'> {
$result['title']}</a></td><td>{
$result['uname']}</td></tr>";
}
echo "</table>";
}else{
echo " There is no message content ";
}
}else{
echo mysqli_error($link);
}
?>
</body>
</html>
<?php
mysqli_close($link);
?>
C:\phpStudy\WWW\PHP\xnfhbbs\showmsg.php
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<h1><a href='./index.php'> In a flash BBS Forum </a></h1>
<?php
include "./inc/dblink.inc.php";
if(isset($_GET['id'])){
$id = $_GET['id'];
$sql = "select * from messages where id =".$id;
//echo $sql;
if($results = mysqli_query($link,$sql)){
$result=mysqli_fetch_assoc($results);
echo $result['uname'].":".$result['title']."<hr />";
echo $result['content'];
}else{
echo mysqli_error($link);
}
}else{
echo "id Error!";
}
mysqli_close($link);
?>
</body>
</html>
C:\phpStudy\WWW\PHP\xnfhbbs\addCont.php
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<h1><a href='./index.php'> In a flash BBS Forum </a></h1>
<?php
include "./inc/dblink.inc.php";
?>
<?php
if(isset($_COOKIE['name'])){
$html =<<<HTML <form method="post" > title :<input type="text" name="userTitle"><br /> Content :<br /> <textarea name="userCont"></textarea> <input type="submit" name="userSubmit" value=" Submit "> </form> HTML;
echo $html."<br />";
if(isset($_POST['userSubmit']) && isset($_POST['userTitle'])){
$userName=$_COOKIE['name'];
$title = mysqli_real_escape_string($link,$_POST['userTitle']);
$cont = mysqli_real_escape_string($link,$_POST['userCont']);
$sql = "INSERT INTO `messages`(`uname`, `title`, `content`) VALUES ('".$userName."', '".$title."','".$cont."')";
if($results = mysqli_query($link,$sql)){
echo " Message success ,<a href='./'> Back to the home page </a>";
}else{
mysqli_close($link);
}
}else{
echo " Please submit ";
}
}else{
echo " You haven't signed in yet ,<a href='./member/'> Please return to the personal Center </a>";
}
?>
<?php
mysqli_close($link);
?>
</body>
</html>
C:\phpStudy\WWW\PHP\xnfhbbs\inc\dblink.inc.php
<?php
$dbHost = "127.0.0.1";
$dbUser = "root";
$dbPass = "root";
$dbName = "xnfh";
$link = mysqli_connect($dbHost,$dbUser,$dbPass,$dbName);
if(!link){
die(mysqli_connect_error());
}
mysqli_set_charset($link,"utf-8");
?>
C:\phpStudy\WWW\PHP\xnfhbbs\member\addUser.php
<meta charset="utf-8">
<?php
include "../inc/dblink.inc.php";
?>
<?php
//var_dump($_POST);
//echo "<hr />";
if(isset($_POST['userSubmit'])){
$userName=$_POST['userName'];
$userPass1=$_POST['userPass1'];
$userPass2=$_POST['userPass2'];
if(
isset($userName) &&
isset($userPass1) &&
isset($userPass2) &&
$userPass1 === $userPass2
){
$sql = "insert into users(name,password) values('".$userName."','".md5($userPass1)."')";
//echo $sql;
if(!mysqli_query($link,$sql)){
die("sql There is a mistake in the sentence ");
}else{
echo " Registered successfully ,<a href='./index.php'> Return to the personal Center ";
setcookie("name",$userName,time()+3600,'/');
}
}else{
echo " Incorrect registration information ,<a href='./register.php'> Please re register </a>";
}
}else{
header("Location:./register.php");// Redirect
}
?>
<?php
mysqli_close($link);
?>
C:\phpStudy\WWW\PHP\xnfhbbs\member\index.php
<?php
include "../inc/dblink.inc.php";
?>
<html>
<head>
<meta charset="utf-8">
<title> home page -- Personal center </title>
</head>
<body>
<h1><a href="../index.php"> In a flash BBS Forum </a></h1>
<?php
if(isset($_COOKIE['name'])){
$userName = $_COOKIE['name'];
$sql = "select * from users where name='".$userName."'";
//echo $sql;
if($results = mysqli_query($link,$sql)){
//echo mysqli_num_rows($results);
if(mysqli_num_rows($results)>0){
$result = mysqli_fetch_assoc($results);
echo "<hr />";
echo " Welcome ,".$result['name']."<a href='./logout.php'> Cancellation </a>";
echo "<hr />";
echo " Your avatar is <img src='".$result['photo']."'>";
echo "<a href='./update.php'> Modify the head image </a>";
echo "<hr />";
echo " The account balance :".$result['money']."<span style='color:red;'> Please contact the Administrator </span>";
}else{
setcookie('name',$_COOKIE['name'],time()-3600,'/PHP/cnfhbbs');
die(" The user does not exist ,<a href='./register.php'> Please register </a> perhaps <a href='../index.php'> Back to the home page </a>");
}
}else{
die(mysqli_error($link));
}
}else{
echo "<a href='./register.php'> register </a>";
echo "<br />";
echo "<a href='./login.php'> Sign in </a>";
}
?>
<?php
mysqli_close($link);
?>
</body>
</html>
C:\phpStudy\WWW\PHP\xnfhbbs\member\login.php
<meta charset="utf-8">
<?php
include "../inc/dblink.inc.php";
?>
<?php
if(isset($_POST['userSubmit'])){
$userName=$_POST['userName'];
$userPass=$_POST['userPass'];
$sql = "select * from users where name='".$userName."' and password='".md5($userPass)."'";
if($results=mysqli_query($link,$sql)){
if(mysqli_num_rows($results)>0){
setcookie('name',$userName,time()+3600*24,'/');
echo " Login successful ,<a href='./index.php'> Return to the personal Center </a>";
}else{
echo " Wrong user name or password ,<a href='./login.php'> Please login again </a>";
}
}else{
die(mysqli_error($link));
}
}else{
$html=<<<HTML <form method="POST" > user name :<input type="text" name="userName"><br /> password :<input type="password" name="userPass"><br /> <input type="submit" name="userSubmit" value=" Sign in "> </form> HTML;
echo $html;
}
?>
<?php
mysqli_close($link);
?>
C:\phpStudy\WWW\PHP\xnfhbbs\member\logout.php
<meta charset="utf-8">
<?php
if(setcookie('name',$_COOKIE['name'],time()-3600,'/')){
echo "Logout!<a href='./index.php'> Return to the personal Center </a>";
}else{
die("Error!");
}
?>
C:\phpStudy\WWW\PHP\xnfhbbs\member\register.php
<html>
<head>
<meta charset="utf-8">
<title> register -- In a flash </title>
</head>
<body>
<h1> In a flash BBS Forum </h1>
<form
action="./addUser.php"
method="POST"
>
user name :<input id="user" type="text" name="userName"><br />
password :<input id="pas1" type="password" name="userPass1"><br />
Confirm the password :<input id="pas2" type="password" name="userPass2"><br />
<script>
function fm(){
var ps1=document.getElementById('pas1');
var ps2=document.getElementById('pas2');
if(ps1.value != ps2.value){
alert(" The two passwords are inconsistent , Please re-enter ");
ps1.value="";
ps2.value="";
}
}
</script>
<input type="submit" onmouseover="fm()" name="userSubmit" value=" register ">
</form>
<hr />
</body>
</html>
C:\phpStudy\WWW\PHP\xnfhbbs\member\update.php
<meta charset="utf-8">
<?php
include "../inc/dblink.inc.php";
?>
<?php
if(isset($_POST['userSubmit'])){
$userName = $_COOKIE['name'];
$tmp_path = $_FILES['up']['tmp_name'];
//echo $tmp_path;
$path = ".\\image\\".$_FILES['up']['name'];
//echo $path;
//echo "<hr />";
if(move_uploaded_file($tmp_path,$path)){
$path = mysqli_real_escape_string($link,$path);
$sql = "update users set photo='".$path."' where name='".$userName."'";
//echo $sql;
if(mysqli_query($link,$sql)){
echo " Image upload succeeded ,<a href='./index.php'> Return to the personal Center </a>";
}else{
die(mysqli_error($link));
}
}else{
echo " Picture upload failed !";
}
}else{
$html=<<<HTML <form method="POST"; enctype="multipart/form-data" > <input type="file" name="up"><br /> <input type="submit" name="userSubmit" value=" Submit "> </form> HTML;
echo $html;
}
?>
<?php
mysqli_close($link);
?>
边栏推荐
- 记一个 @nestjs/typeorm^8.1.4 版本不能获取.env选项问题
- Keepalive component cache does not take effect
- Leetcode1961. 检查字符串是否为数组前缀
- FFT 学习笔记(自认为详细)
- BiShe - College Student Association Management System Based on SSM
- Pbootcms plug-in automatically collects fake original free plug-ins
- DD's command
- View class diagram in idea
- Finding the nearest common ancestor of binary search tree by recursion
- Dynamic programming -- linear DP
猜你喜欢

Test de vulnérabilité de téléchargement de fichiers basé sur dvwa
![[groovy] compile time metaprogramming (compile time method injection | method injection using buildfromspec, buildfromstring, buildfromcode)](/img/e4/a41fe26efe389351780b322917d721.jpg)
[groovy] compile time metaprogramming (compile time method injection | method injection using buildfromspec, buildfromstring, buildfromcode)

WordPress collection plug-in automatically collects fake original free plug-ins

Intensive learning weekly, issue 52: depth cuprl, distspectrl & double deep q-network

3D模型格式汇总

cf:H. Maximal AND【位运算练习 + k次操作 + 最大And】

关于#数据库#的问题:(5)查询库存表中每本书的条码、位置和借阅的读者编号

Some features of ECMAScript
![Cf:h. maximum and [bit operation practice + K operations + maximum and]](/img/c2/9e58f18eec2ff92e164d8d156629cf.png)
Cf:h. maximum and [bit operation practice + K operations + maximum and]

The inconsistency between the versions of dynamic library and static library will lead to bugs
随机推荐
The detailed page returns to the list and retains the original position of the scroll bar
Mlsys 2020 | fedprox: Federation optimization of heterogeneous networks
Recursive method to realize the insertion operation in binary search tree
基於DVWA的文件上傳漏洞測試
How to extract MP3 audio from MP4 video files?
What is the most suitable book for programmers to engage in open source?
Dedecms plug-in free SEO plug-in summary
MIT doctoral thesis | robust and reliable intelligent system using neural symbol learning
IP storage and query in MySQL
1791. Find the central node of the star diagram / 1790 Can two strings be equal by performing string exchange only once
The value of applet containers
Logstash clear sincedb_ Path upload records and retransmit log data
基于DVWA的文件上传漏洞测试
Distributed base theory
Keepalive component cache does not take effect
Vulhub vulnerability recurrence 74_ Wordpress
普通人下场全球贸易,新一轮结构性机会浮出水面
The population logic of the request to read product data on the sap Spartacus home page
DOM introduction
程序员搞开源,读什么书最合适?