Hướng dẫn view profile php - xem hồ sơ php

Trong bài viết trước, chúng tôi đã tìm hiểu về việc tạo ra một biểu mẫu đăng nhập đơn giản bằng cách sử dụng PHP và MySQL, và Tạo một biểu mẫu đăng ký đơn giản bằng cách sử dụng PHP và MySQL. Trong bài viết này, chúng tôi sẽ học cách tạo trang hồ sơ người dùng. Người dùng sẽ cần nhập các chi tiết cơ bản để đăng ký và sau đó có thể sử dụng thông tin đăng nhập để đăng nhập. Vì vậy, chúng ta hãy tiến hành các bước dưới đây.Creating a simple login form using PHP and Mysql” and “Creating a simple registration form using PHP and Mysql“. In this article, we are going to learn how to create a user profile page. User will need to input basic details to register himself and after that same credentials can be used to login. So let us proceed with the below steps.Creating a simple login form using PHP and Mysql” and “Creating a simple registration form using PHP and Mysql“. In this article, we are going to learn how to create a user profile page. User will need to input basic details to register himself and after that same credentials can be used to login. So let us proceed with the below steps.

Nội dung chính ShowShow

  • 1. Tạo trang chính
  • 2. Đưa ra phong cách cho trang
  • 3. Kết nối với cơ sở dữ liệu
  • 4. Tạo bảng người dùng
  • 5. Mẫu đăng ký xử lý
  • 6. Xử lý mẫu đăng nhập.
  • 7. Tạo phiên người dùng.
  • 8. Tạo trang chào mừng/hồ sơ.
  • 9. Quy trình đăng nhập vào nút và xóa tài khoản.
  • Làm cách nào để xem chi tiết người dùng trong PHP?
  • Làm thế nào tôi có thể thấy tên người dùng chào mừng của tôi trong PHP?
  • Row $ trong PHP là gì?
  • Hồ sơ PHP là gì?

Nội phân Chính showShowShow

  • 1. Tạo trang chính
  • 2. Đưa ra phong cách cho trang
  • 3. Kết nối với cơ sở dữ liệu
  • 4. Tạo bảng người dùng
  • 5. Mẫu đăng ký xử lý
  • 6. Xử lý mẫu đăng nhập.
  • 7. Tạo phiên người dùng.
  • 8. Tạo trang chào mừng/hồ sơ.
  • 9. Quy trình đăng nhập vào nút và xóa tài khoản.
  • Làm cách nào để xem chi tiết người dùng trong PHP?
  • Làm thế nào tôi có thể thấy tên người dùng chào mừng của tôi trong PHP?
  • Row $ trong PHP là gì?
  • Hồ sơ PHP là gì?

Nội phân Chính showShow

  • 1. Tạo trang chính
  • 2. Đưa ra phong cách cho trang
  • 3. Kết nối với cơ sở dữ liệu
  • 4. Tạo bảng người dùng
  • 5. Mẫu đăng ký xử lý
  • 6. Xử lý mẫu đăng nhập.
  • 7. Tạo phiên người dùng.
  • 8. Tạo trang chào mừng/hồ sơ.
  • 9. Quy trình đăng nhập vào nút và xóa tài khoản.
  • Làm cách nào để xem chi tiết người dùng trong PHP?
  • Làm thế nào tôi có thể thấy tên người dùng chào mừng của tôi trong PHP?
  • Row $ trong PHP là gì?
  • Hồ sơ PHP là gì?
  1. Nội phân Chính showShow
  2. Làm thế nào tôi có thể thấy tên người dùng chào mừng của tôi trong PHP?
  3. Nội phân chính
  4. Tạo trang chính.
  5. Đưa ra phong cách cho trang.
  6. Kết nối với cơ sở dữ liệu.
  7. Tạo bảng người dùng.
  8. Mẫu đăng ký xử lý.
  9. Xử lý mẫu đăng nhập.

1. Tạo trang chính

Tạo phiên người dùng.

index.php

<?php include "logincheck.php"; ?>
<!DOCTYPE html>
<html>
<head>
 <meta content='text/html; charset=UTF-8' http-equiv='Content-Type'/>
 <link rel="stylesheet" type="text/css" href="style.css" />
 <title>7topics - Login Demo</title>
</head>
<body>
<header>
 <nav>
  <ul>
   <li><a href="https://7topics.com">7topics</a></li>
   <li><a href="https://7topics.com/creating-user-profile-page-using-php-and-mysql.html">Tutorial</a></li>
  </ul>
 </nav>
</header>
<div id="center">
<div id="center-set"> -written by Rahul Ranjan 
<div id="signup">
<div id="signup-st">
<div align="center">
<?php
$remarks = isset($_GET['remarks']) ? $_GET['remarks'] : '';
if ($remarks==null and $remarks=="") {
echo ' <div id="reg-head" class="headrg">Register Here</div> ';
}
if ($remarks=='success') {
echo ' <div id="reg-head" class="headrg">Registration Success</div> ';
}
if ($remarks=='failed') {
echo ' <div id="reg-head-fail" class="headrg">Registration Failed!, Username exists</div> ';
}
if ($remarks=='error') {
echo ' <div id="reg-head-fail" class="headrg">Registration Failed! <br> Error: '.$_GET['value'].' </div> ';
}
?>
</div>
<form name="reg" action="execute.php" onsubmit="return validateForm()" method="post" id="reg">
<table border="0" align="center" cellpadding="2" cellspacing="0">
<tr>
<td class="t-1">
<div align="left" id="tb-name">First&nbsp;Name:</div>
</td>
<td width="171">
<input type="text" name="fname" id="tb-box"/>
</td>
</tr>
<tr>
<td class="t-1"><div align="left" id="tb-name">Last&nbsp;Name:</div></td>
<td><input type="text" name="lname" id="tb-box"/></td>
</tr>
<tr>
<td class="t-1"><div align="left" id="tb-name">Email:</div></td>
<td><input type="text" id="tb-box" name="address" /></td>
</tr>
<tr>
<td class="t-1"><div align="left" id="tb-name">Username:</div></td>
<td><input type="text" id="tb-box" name="username" /></td>
</tr>
<tr>
<td class="t-1"><div align="left" id="tb-name">Password:</div></td>
<td><input id="tb-box" type="password" name="password" /></td>
</tr>
</table>
<div id="st"><input name="submit" type="submit" value="Submit" id="st-btn"/></div>
</form>
<div id="reg-bottom" class="btmrg">Copyright &copy; 2015 7topics.com</div>
</div>
</div>
<div id="login">
<div id="login-st">
<form action="" method="POST" id="signin" id="reg">
<?php
$remarks = isset($_GET['remark_login']) ? $_GET['remark_login'] : '';
if ($remarks==null and $remarks=="") {
echo ' <div id="reg-head" class="headrg">Login Here</div> ';
}
if ($remarks=='failed') {
echo ' <div id="reg-head-fail" class="headrg">Login Failed!, Invalid Credentials</div> ';
}
?>
<table border="0" align="center" cellpadding="2" cellspacing="0">
<tr id="lg-1">
<td class="tl-1"><div align="left" id="tb-name">Username:</div></td>
<td><input type="text" id="tb-box" name="username" /></td>
</tr>
<tr id="lg-1">
<td class="tl-1"><div align="left" id="tb-name">Password:</div></td>
<td><input id="tb-box" type="password" name="password" /></td>
</tr>
</table>
<div id="st"><input name="submit" type="submit" value="Login" id="st-btn"/></div>
</form>
<div id="reg-bottom" class="btmrg">Copyright &copy; 2015 7topics.com</div>
</div>
</div>
</div>
</div>
<div id="footer"><p> Copyright &copy; 2014-2020 7topics.com </p></div>
</body>
</html>

2. Đưa ra phong cách cho trang

Tạo trang chào mừng/hồ sơ.

style.css

body,li,ul{
 margin:0px auto;
}
body{
 background-color:#3498DB;
 width:100%;
 font-family:sans-serif;
}
header{
 background-color:#fff;
 width:100%;
 height:55px;
 margin:0px;
}
nav{
 width:100%;
 border-top:5px solid #3498DB;
}
nav ul{
 float:left;
 border-left:6px solid #BDC3C7;
 height:50px;
}
nav a{
 text-decoration:none;
 color:#3498DB;
 padding:10px;
 width:auto;
 font-size:30px;
 font-weight:bold;
 border-right:1px solid #BDC3C7;
 font-family:Gabriola;
 height:50px;
}
nav a:hover{
 color:#fff;
 background-color:#3498DB;
 transition:1s;
}
nav li{
 margin:0;
 padding:0;
 list-style:none;
 float:left;
}

#center{
 margin:0px auto;
 width:95%;
}
#center-set{
 float:left;
 width:100%;
 padding-top:1%;
 padding-bottom:0.5%;
 background-color:#A2DED0;
 border-top:5px solid #3498DB;
}
#signup{
 float:left;
 width:50%;
}
#signup-st,#login-st{
 background-color:#22313F;
 margin:50px;
 border-radius:20px;
 -webkit-box-shadow: 3px 3px 4px 0px rgba(0,0,0,0.85);
}
#reg{
 padding-top:10px;
}
#reg-head,#reg-bottom,#reg-head-fail{
 width:100%;
 text-align:center;
 background-color:#fff;
 font-weight:bold;
}
.headrg{
 border-top-left-radius:20px;
 border-top-right-radius:20px;
 padding-top:12px;
 padding-bottom:12px;
 font-size:22px;
 color:#6C7A89;
}
.btmrg{
 padding-top:5px;
 padding-bottom:5px;
 border-bottom-left-radius:20px;
 border-bottom-right-radius:20px;
 font-size:18px;
 color:#22313F;
}
#reg-head-fail{
 color:#D35400;
}
#reg-head:hover{
 color:#3498DB;
 transition:1s;
}
#tb-name{
 float:right;
 font-size:20px;
}
#tb-box{
 height:22px;
 width:200px;
}
#st{
 width:100%;
 text-align:center;
 padding-top:30px;
 padding-bottom:10px;
}
#st-btn{
 text-align:center;
 padding:10px 21px 10px 21px;
 background-color:#3498DB;
 border:none;
 color:#fff;
 cursor:pointer;
 font-size:20px;
 font-weight:bold;
}
#st-btn:hover{
 color:#3498DB;
 background:#fff;
 transition:1s;
}
td.t-1{
 float:left;
 width:44%;
 text-align:right;
 color:#C5EFF7;
}
td.t-2{
 float:right;
 width:55%;
}
#lg-1{
 padding:10px;
 float:left;
 width:95%;
}
.tl-1{
 float:left;
 width:40%;
 padding-right:5%;
 text-align:center;
 color:#C5EFF7;
}
.tl-4{
 font-size:17px;
 font-weight:bold;
 text-align:center;
 color:#FDE3A7;
}
#login{
 float:right;
 width:50%;
}
#login-sg{
 margin-top:20%;
}
#footer{
 background-color:#fff;
 width:100%;
 height:50px;
 margin:0px;
 float:left;
 border-top:5px solid #3498DB;
}
#footer p{
 text-align:center;
 font-size:18px;
 font-weight:bold;
 color:#3498DB;
}

3. Kết nối với cơ sở dữ liệu

Quá trình đăng nhập vào và nút Xóa tài khoản.

db.php

<?php 
$mysql_hostname = "localhost";
$mysql_user = "username";
$mysql_password = "password";
$mysql_database = "database";
$con = mysqli_connect($mysql_hostname, $mysql_user, $mysql_password, $mysql_database);
?>

4. Tạo bảng người dùng

5. Mẫu đăng ký xử lý

member.sql

6. Xử lý mẫu đăng nhập.

5. Mẫu đăng ký xử lý

6. Xử lý mẫu đăng nhập.

execute.php

<?php 
session_start();
include('db.php');
$username=$_POST['username'];
$result = mysqli_query($con,"SELECT * FROM member WHERE username='$username'");
$num_rows = mysqli_num_rows($result);
if ($num_rows) {
 header("location: index.php?remarks=failed"); 
}else {
 $fname=$_POST['fname'];
 $lname=$_POST['lname'];
 $address=$_POST['address'];
 $username=$_POST['username'];
 $password=$_POST['password'];
 if(mysqli_query($con,"INSERT INTO member(fname, lname, address,username, password)VALUES('$fname', '$lname','$address', '$username', '$password')")){ 
 header("location: index.php?remarks=success");
 }else{
  $e=mysqli_error($con);
 header("location: index.php?remarks=error&value=$e");  
 }
}
?>

6. Xử lý mẫu đăng nhập.

7. Tạo phiên người dùng.

logincheck.php

<?php
include("db.php");
session_start();
if($_SERVER["REQUEST_METHOD"] == "POST") {
 $username=mysqli_real_escape_string($con,$_POST['username']);
 $password=mysqli_real_escape_string($con,$_POST['password']);
 $result = mysqli_query($con,"SELECT * FROM member");
 $c_rows = mysqli_num_rows($result);
 if ($c_rows!=$username) {
  header("location: index.php?remark_login=failed");
 }
 $sql="SELECT mem_id FROM member WHERE username='$username' and password='$password'";
 $result=mysqli_query($con,$sql);
 $row=mysqli_fetch_array($result);
 $active=$row['active'];
 $count=mysqli_num_rows($result);
 if($count==1) {
  $_SESSION['login_user']=$username;
  header("location: welcome.php");
 }
}
?>

7. Tạo phiên người dùng.

8. Tạo trang chào mừng/hồ sơ.

session.php

<?php
include('db.php');
session_start();
$user_check=$_SESSION['login_user'];
$ses_sql=mysqli_query($con,"select username,mem_id from member where username='$user_check'");
$row=mysqli_fetch_array($ses_sql,MYSQLI_ASSOC);
$loggedin_session=$row['username'];
$loggedin_id=$row['mem_id'];
if(!isset($loggedin_session) || $loggedin_session==NULL) {
 echo "Go back";
 header("Location: index.php");
}
?>

8. Tạo trang chào mừng/hồ sơ.

9. Quy trình đăng nhập vào nút và xóa tài khoản.

welcome.php

Làm cách nào để xem chi tiết người dùng trong PHP?

9. Quy trình đăng nhập vào nút và xóa tài khoản.

Làm cách nào để xem chi tiết người dùng trong PHP?

logout.php

<?php
session_start();
if(session_destroy()) {
 header("Location: index.php");
}
?>

Làm thế nào tôi có thể thấy tên người dùng chào mừng của tôi trong PHP?

<?php
include('session.php');
?>
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<div id="contentbox" >
<script type="text/javascript">
function countdown() {
 var i = document.getElementById('timecount');
 if (parseInt(i.innerHTML)<=1) {
  location.href = 'index.php';
 }
 i.innerHTML = parseInt(i.innerHTML)-1;
}
setInterval(function(){ countdown(); },1000);
</script>
<?php
$id=$loggedin_id;
$sql="DELETE FROM member WHERE mem_id='$id'";
$result=mysqli_query($con,$sql);
if($result){
 echo " <div align='center'>";
 echo "Account Deleted Sucessfully.";
 echo " <a href='index.php' >Click here</a> to go back. ";
 echo "</div> ";
} elseif(!isset($loggedin_session) || $loggedin_session==NULL) {
 header("Location: index.php");
} else {
 echo "Unable to delete Your Account";
}
?>
</div>
</body>
</html>
</div>

Row $ trong PHP là gì?

Hồ sơ PHP là gì?

Nội phân Chính showShow

Làm cách nào để xem chi tiết người dùng trong PHP?

Làm thế nào tôi có thể thấy tên người dùng chào mừng của tôi trong PHP? php page asks for the desired username, email, and password of the user, and then sends the entered data into the database, once the submit button is clicked. After this, the user is redirected to the index. php page where a welcome message and the username of the logged-in user is displayed.

Làm thế nào tôi có thể thấy tên người dùng chào mừng của tôi trong PHP?

Row $ trong PHP là gì?$_SESSION['username'] = $myusername; $_SESSION['password'] = $mypassword; Because $myusername and $mypassword refer to the username and password sent to the script from the form data.

Row $ trong PHP là gì?

Hồ sơ PHP là gì?Returns an array of strings that corresponds to the fetched row. NULL if there are no more rows in result set. PHP Version: 5+

Hồ sơ PHP là gì?

Nội phân Chính showShowa tool that measures how some code consumes resources at run-time. It enables to find performance bottlenecks and understand the code's behavior. Blackfire Profiler for PHP enables to profile applications during development, test, staging, and production environments.