Hướng dẫn how to make edit profile page in php? - làm cách nào để chỉnh sửa trang hồ sơ trong php?

Tại đây, bạn có thể tìm hiểu cách tạo mô -đun ‘Thay đổi/chỉnh sửa mô -đun trong PHP mà không còn nghi ngờ gì nữa.

Nếu bạn muốn xây dựng thay đổi mô -đun mật khẩu trong PHP. Tôi khuyên bạn nên truy cập bài viết này của tôi để có được toàn bộ ý tưởng thay đổi mô -đun mật khẩu với đoạn mã trong PHP.this article to get the entire idea of Change Password module with code snippets in PHP.

Bây giờ, hãy để nói về việc tạo ra thay đổi/chỉnh sửa cơ chế hồ sơ trong hệ thống của chúng tôi.

Trước hết, bạn phải tạo một tệp kết nối để kết nối với cơ sở dữ liệu.

Connection.php

<?php
$dbservername="localhost";
$dbuser="root";
$dbpass="";
$dbname="your_database_name";
$conn=mysqli_connect($dbservername,$dbuser,$dbpass,$dbname);
?>

Bây giờ, bạn phải tạo biểu mẫu cấu hình chỉnh sửa có chứa tất cả các trường của người dùng

Profile_edit_form.php

<form action="Profile_update.php" method="post">   fname: <input type="text" name="fname"><br>

lname: <input type="text" name="lname"><br>

email: <input type="email" name="email"><br>

<input type="submit" name="edit">

</form>

Sau khi tất cả dữ liệu điền, tất cả dữ liệu được truyền đến accord_update.php.

Trong hồ sơ_update.php, nó kiểm tra xem ID người dùng có khớp chính xác với ID tìm nạp từ cơ sở dữ liệu hay không. Nếu giống nhau thì nó sẽ cập nhật dữ liệu mới với dữ liệu cũ.

Profile_update.php

<?php

session_start();
include "Connection.php";

if(isset($_POST['edit']))
{
$id=$_SESSION['id'];
$fname=$_POST['fname'];
$lname=$_POST['lname'];
$email=$_POST['email'];
$select= "select * from users where id='$id'";
$sql = mysqli_query($conn,$select);
$row = mysqli_fetch_assoc($sql);
$res= $row['id'];
if($res === $id)
{

$update = "update users set fname='$fname',lname='$lname',email='$email' where id='$id'";
$sql2=mysqli_query($conn,$update);

if($sql2)
{
/*Successful*/
header('location:Dashboard.php');
}
else
{
/*sorry your profile is not update*/
header('location:Profile_edit_form.php');
}
}
else
{
/*sorry your id is not match*/
header('location:Profile_edit_form.php');
}
}?>

Chúc mừng! Bạn tốt để đi.

Nếu bạn muốn thực hiện cơ chế đăng ký đăng nhập của bạn, bạn chắc chắn nên kiểm tra dưới đây.

Nếu bạn muốn làm cho giao diện người dùng web của bạn hấp dẫn hơn, bạn chắc chắn nên kiểm tra các bài viết dưới đây.

Tôi hy vọng bạn đã tìm thấy bài viết này thông tin và hữu ích. Tôi rất thích nghe phản hồi của bạn!

Cảm ơn vì đã đọc! :)

Chúc mọi người một ngày tốt lành! Hôm nay là một hướng dẫn khác cho tất cả các nhà phát triển PHP, đặc biệt là cho người mới bắt đầu lập trình PHP. Tôi sẽ dạy bạn tạo một hồ sơ người dùng đơn giản với thông tin hồ sơ cập nhật bằng PHP/MySQL.Simple User Profile With Update Profile Info Using PHP/MYSQL.

Bài viết này có thể trả lời câu hỏi được đăng trong StackOverflow về cách xem hồ sơ người dùng bằng cách sử dụng PHP.

Nhưng trước đó, hãy chắc chắn rằng bạn đã hoàn thành việc tạo một đăng nhập và đăng ký đơn giản. Nếu bạn chưa, hướng dẫn này có thể giúp bạn. >> Bấm vào đâycreating a simple login and registration. If you are not yet, this tutorial might help you. >> click here <<

Các bước để tạo & nbsp; Hồ sơ người dùng với thông tin cấu hình cập nhật bằng Php/MySQL

Bước 1. Đầu tiên, tạo cơ sở dữ liệu, đặt tên cho nó là bất kỳ tên nào bạn mong muốn. Trong trường hợp của tôi, tôi sử dụng của ItsourceCecode, tên là tên của cơ sở dữ liệu. First, create a database, name it as any name you desire. In my case, I use “ITSOURCECODE” as the name of the database.

Bước 2. Sau đó tạo bảng người dùng của người dùng sau đó đặt các thuộc tính sau. Then create the”USERS” table then put the following attributes.

CREATE TABLE `users` (  `user_id` int(11) NOT NULL,
  `username` text NOT NULL, 
 `password` text NOT NULL,
  `full_name` text NOT NULL, 
 `gender` text NOT NULL, 
 `age` int(11) NOT NULL, 
 `address` text NOT NULL) 
ENGINE=MyISAM DEFAULT CHARSET=latin1;

Hãy chắc chắn rằng bạn đã hoàn thành việc đăng nhập và đăng ký. Một liên kết sẽ được nhìn thấy và xem trên liên kết ở trên. Và đảm bảo tạo tệp kết nối trực tuyến.php để giữ kết nối cơ sở dữ liệu với dự án PHP của chúng tôi.

<?php
 $db = mysqli_connect('localhost', 'root', '') or
        die ('Unable to connect. Check your connection parameters.');
        mysqli_select_db($db, 'mydb' ) or die(mysqli_error($db));
?>

Bước 3. Đối với hồ sơ của người dùng, hãy tạo và cập nhật tệp hồ sơ của Google.php, sau đó đặt các mã sau. For the user’s profile, create and update “profile.php” file then put the following codes.

<!DOCTYPE html>
<html lang="en-US">
  <head>
  <title>IT SourceCode</title>
  <link rel="stylesheet" href="libs/css/bootstrap.min.css">
  <link rel="stylesheet" href="libs/style.css">
  </head>
  <?php
  include 'connection.php';
  session_start();
$id=$_SESSION['id'];
$query=mysqli_query($db,"SELECT * FROM users where user_id='$id'")or die(mysqli_error());
$row=mysqli_fetch_array($query);
  ?>
  <h2>User Profile</h2>
<div class="profile-input-field">
        <h3>Please Fill-out All Fields</h3>
        <form method="post" action="#" >
          <div class="form-group">
            <label>Fullname</label>
            <input type="text" class="form-control" name="fname" style="width:20em;" placeholder="Enter your Fullname" value="<?php echo $row['full_name']; ?>" required />
          </div>
          <div class="form-group">
            <label>Gender</label>
            <input type="text" class="form-control" name="gender" style="width:20em;" placeholder="Enter your Gender" required value="<?php echo $row['gender']; ?>" />
          </div>
          <div class="form-group">
            <label>Age</label>
            <input type="number" class="form-control" name="age" style="width:20em;" placeholder="Enter your Age" value="<?php echo $row['age']; ?>">
          </div>
          <div class="form-group">
            <label>Address</label>
            <input type="text" class="form-control" name="address" style="width:20em;" required placeholder="Enter your Address" value="<?php echo $row['address']; ?>"></textarea>
          </div>
          <div class="form-group">
            <input type="submit" name="submit" class="btn btn-primary" style="width:20em; margin:0;"><br><br>
            <center>
             <a href="logout.php">Log out</a>
           </center>
          </div>
        </form>
      </div>
      </html>
      <?php
      if(isset($_POST['submit'])){
        $fullname = $_POST['fname'];
        $gender = $_POST['gender'];
        $age = $_POST['age'];
        $address = $_POST['address'];
      $query = "UPDATE users SET full_name = '$fullname',
                      gender = '$gender', age = $age, address = '$address'
                      WHERE user_id = '$id'";
                    $result = mysqli_query($db, $query) or die(mysqli_error($db));
                    ?>
                     <script type="text/javascript">
            alert("Update Successfull.");
            window.location = "index.php";
        </script>
        <?php
             }               
?>

Bước 4. Cập nhật tệp index index.php bằng cách đặt các mã sau. Update the “index.php” file by putting the following codes.

<!DOCTYPE html>
<html lang="en-US">
  <head>
  <title>IT SourceCode</title>
  <link rel="stylesheet" href="libs/css/bootstrap.min.css">
  <link rel="stylesheet" href="libs/style.css">
  </head>
  <h2>User Log In</h2>
<div class="input-field">
        <h3>Please Fill-out All Fields</h3>
        <form method="post" action="#" >
          <div class="form-group">
            <label>Username</label>
            <input type="text" class="form-control" name="user" style="width:20em;" placeholder="Enter your Username" required />
          </div>
          <div class="form-group">
            <label>Password</label>
            <input type="password" class="form-control" name="pass" style="width:20em;" placeholder="Enter your Password" required />
          </div>
          <div class="form-group">
            <input type="submit" name="submit" class="btn btn-primary submitBtn" style="width:20em; margin:0;" /><br><br>
            <center>
             <a href="register.php">register</a>
           </center>
          </div>
          
        </form>
      </div>
      </html>
      <?php
      session_start();
      include 'connection.php';
if(isset($_POST['submit'])){
  $user = $_POST['user'];
  $pass = $_POST['pass'];
  $query=mysqli_query($db,"SELECT * FROM users WHERE username = '$user' AND password = '$pass'");
  $num_rows=mysqli_num_rows($query);
  $row=mysqli_fetch_array($query);
  $_SESSION["id"]=$row['user_id'];
if ($num_rows>0)
{
    ?>
    <script>
      alert('Successfully Log In');
      document.location='profile.php'
    </script>
    <?php
}
}
      ?>

Bước 5. Để đăng ký thông tin hồ sơ người dùng, hãy tạo tệp đăng ký.php, sau đó đặt các mã sau. For registration of user profile information, create “register.php” file then put the following codes.

<!DOCTYPE html>
<html lang="en-US">
  <head>
  <title>IT SourceCode</title>
  <link rel="stylesheet" href="libs/css/bootstrap.min.css">
  <link rel="stylesheet" href="libs/style.css">
  </head>
  <h2>Register</h2>
<div class="reg-input-field">
        <h3>Please Fill-out All Fields</h3>
        <form method="post" action="#" >
          <div class="form-group">
            <label>Fullname</label>
            <input type="text" class="form-control" name="fname" style="width:20em;" placeholder="Enter your Fullname" required />
          </div>
          <div class="form-group">
            <label>Gender</label>
            <input type="text" class="form-control" name="gender" style="width:20em;" placeholder="Enter your Gender" required pattern="[a-zA-Z .]+" />
          </div>
          <div class="form-group">
            <label>Age</label>
            <input type="number" class="form-control" name="age" style="width:20em;" placeholder="Enter your Age">
          </div>
          <div class="form-group">
            <label>Address</label>
            <input type="text" class="form-control" name="address" style="width:20em;" required placeholder="Enter your Address"></textarea>
          </div>
          <div class="form-group">
            <label>Username</label>
            <input type="text" class="form-control" name="user" style="width:20em;" placeholder="Enter your Username">
          </div><div class="form-group">
            <label>Password</label>
            <input type="Password" class="form-control" name="pass" style="width:20em;" required  placeholder="Enter your Password">
          </div>
          <div class="form-group">
            <input type="submit" name="submit" class="btn btn-primary submitBtn" style="width:20em; margin:0;" /><br><br>
             <center>
             <a href="index.php">LogIn</a>
           </center>
          </div>
        </form>
      </div>
      </html>
      <?php
      include 'connection.php';
if(isset($_POST['submit'])){
$fname = $_POST['fname'];
$gender = $_POST['gender'];
$age = $_POST['age'];
$address = $_POST['address'];
$user = $_POST['user'];
$pass = $_POST['pass'];


  $query = "INSERT INTO users
                (username, password, full_name,gender,age,address)
                VALUES ('".$user."','".$pass."','".$fname."','".$gender."','".$age."','".$address."')";
                mysqli_query($db,$query)or die ('Error in updating Database');
                ?>
                <script type="text/javascript">
            alert("Successfull Added.");
            window.location = "index.php";
        </script>
                <?php
}
      ?>

Bước 6. Đối với việc đăng xuất của hành động người dùng, hãy tạo tệp đăng nhập.php.php, sau đó đặt các mã sau. For the logout of user action, create “logout.php” file then put the following codes.

<?php
session_start();
unset($_SESSION['id']);
session_destroy();
header("Location: index.php");
?>

Sau khi tất cả các mã đã được thêm vào, bây giờ bạn có thể kiểm tra mã bằng cách chạy nó để sử dụng trình duyệt mong muốn của bạn.

Để biết thêm các dự án PHP có mã nguồn, vui lòng truy cập liên kết tại đây.

Ảnh chụp màn hình mẫu:

Hướng dẫn how to make edit profile page in php? - làm cách nào để chỉnh sửa trang hồ sơ trong php?

Hướng dẫn how to make edit profile page in php? - làm cách nào để chỉnh sửa trang hồ sơ trong php?

Mã nguồn có thể tải xuống

Tải xuống mã nguồn đầy đủ ở đây. Thông tin người dùng

Thắc mắc

Nếu bạn có câu hỏi liên quan đến hồ sơ người dùng đơn giản với thông tin hồ sơ cập nhật bằng Php/MySQL, hãy hỏi bằng cách bình luận bên dưới hoặc truy cập trên trang liên hệ của chúng tôi. Cảm ơn bạn.“Simple User Profile With Update Profile Info Using PHP/MYSQL” feel free to ask by commenting below or visit on our contact page. Thank you.

Làm thế nào để tạo một trang hồ sơ bằng PHP?

Tạo trang hồ sơ người dùng bằng PHP và MySQL..
Tạo trang chính ..
Đưa ra phong cách cho trang ..
Kết nối với cơ sở dữ liệu ..
Tạo bảng người dùng ..
Mẫu đăng ký xử lý ..
Biểu mẫu đăng nhập xử lý ..
Tạo phiên người dùng ..
Tạo trang chào mừng/hồ sơ ..

Làm thế nào tôi có thể tải lên một hình ảnh hồ sơ trong PHP?

Xử lý hình ảnh hồ sơ người dùng bằng Froala và PHP - Hướng dẫn..
Bước 1: Hoàn thành Mã HTML biểu mẫu ..
Giải thích mã khởi tạo Froala ..
Bước 2: Tải xuống SDK FROALA PHP ..
Bước 3: Tải lên và lưu trữ hình ảnh từ thiết bị của bạn lên máy chủ ..
Hiển thị hình ảnh đã tải lên thay vì hình ảnh giữ chỗ khi một trang được làm mới ..

Làm thế nào lấy dữ liệu từ cơ sở dữ liệu của một người dùng cụ thể sau khi đăng nhập PHP?

Lấy hoặc tìm nạp dữ liệu từ cơ sở dữ liệu trong PHP..
Chọn Cột_Name (S) từ Table_Name ..
$ query = mysql_query ("Chọn * từ TableName", $ Connection) ;.
$ Kết nối = mysql_connect ("localhost", "root", "") ;.
$ db = mysql_select_db ("công ty", $ kết nối) ;.
$ query = mysql_query ("Chọn * từ nhân viên", $ Connection) ;.