By GokiSoft.com| 19:23 10/01/2024|
Học PHP

Form đăng ký tài khoản người dùng - Registation Form trong PHP - Lập trình PHP - Lập Trình PHP MySQL BT1615

Viết form đăng ký tài khoản người dùng như hình sau (input.php)

Khi người dùng click vào register => Nếu tên người dùng là @tên bạn & mật khẩu có giá trị là 123.

Hiển thị trang welcome.php hiển thị tất cả thông tin người dùng vừa đăng ký.

Ví dụ:

Tên Tài Khoảngokisoft
Emailgokisoft.com@gmail.com
Mật Khẩu123456 (edit)

Khi người dùng click vào edit thì hiển thị thông tin ra trang input.php => cho phép sửa lại các thông tin đó.

Liên kết rút gọn:

https://gokisoft.com/1615

Bình luận

avatar
GokiSoft.com [Teacher]
2022-04-08 03:34:24


#bt2837.php


<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<title>Register Form</title>
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
	<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>

	<style type="text/css">
		.form-group {
			margin-bottom: 20px;
		}
	</style>
</head>
<body>
<div class="container">
<?php
// Sinh ngẫu nhiên 1 số tự nhiên N từ 3 -> 15
$n = rand(3, 15);

// Tạo mảng $bookList = []
$bookList = [];

// Sinh ngẫu nhiên N mảng key => value gồm các key: title, thumbnail, price -> Add từng mảng key -> value vào mảng $bookList
for ($i=0; $i < $n; $i++) {
	$item = [
		'title' => 'Sach '.$i,
		'thumbnail' => 'https://gokisoft.com/uploads/stores/49/2021/10/coding-c-program.jpg',
		'price' => 1000 + 200 * $i
	];
	$bookList[] = $item;
}

// var_dump($bookList);
?>
<table class="table table-bordered">
	<thead>
		<tr>
			<th>No</th>
			<th>Thumbnail</th>
			<th>Title</th>
			<th>Price</th>
		</tr>
	</thead>
	<tbody>
<?php
$index = 0;
foreach($bookList as $item) {
	echo '<tr>
			<td>'.(++$index).'</td>
			<td><img src="'.$item['thumbnail'].'" style="width: 100px"/></td>
			<td>'.$item['title'].'</td>
			<td>'.$item['price'].'</td>
		</tr>';
}
?>
	</tbody>
</table>
</div>
</body>
</html>


#detail1.php


<?php
$fullname = $email = $password = "";
if(!empty($_GET)) {
	if(isset($_GET['fullname'])) {
		$fullname = $_GET['fullname'];
	}

	if(isset($_GET['email'])) {
		$email = $_GET['email'];
	}

	if(isset($_GET['pwd'])) {
		$password = $_GET['pwd'];
	}
}
?>
<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<title>Register Form</title>
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
	<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>

	<style type="text/css">
		.form-group {
			margin-bottom: 20px;
		}
	</style>
</head>
<body>
<div class="container">
	<table class="table table-bordered">
		<thead>
			<tr>
				<th>Full Name</th>
				<th>Email</th>
				<th>Password</th>
			</tr>
		</thead>
		<tbody>
			<tr>
				<td>
					<?php
						echo $fullname;
					?>
				</td>
				<td>
					<?php
						print($email);
					?>
				</td>
				<td><?=$password?></td>
			</tr>
		</tbody>
	</table>
</div>
</body>
</html>


#detail2.php


<?php
$fullname = $email = $password = "";
if(!empty($_GET)) {
	if(isset($_GET['fullname'])) {
		$fullname = $_GET['fullname'];
	}

	if(isset($_GET['email'])) {
		$email = $_GET['email'];
	}

	if(isset($_GET['pwd'])) {
		$password = $_GET['pwd'];
	}
}
?>
<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<title>Register Form</title>
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
	<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>

	<style type="text/css">
		.form-group {
			margin-bottom: 20px;
		}
	</style>
</head>
<body>
<div class="container">
	<table class="table table-bordered">
		<thead>
			<tr>
				<th>Full Name</th>
				<th>Email</th>
				<th>Password</th>
			</tr>
		</thead>
		<tbody>
			<tr>
				<td>
					<?php
						echo $fullname;
					?>
				</td>
				<td>
					<?php
						print($email);
					?>
				</td>
				<td>
					<?=$password?>
					<a href="post.php?<?="fullname=$fullname&email=$email&pwd=$password"?>"><button class="btn btn-sm btn-warning">Edit</button></a>
				</td>
			</tr>
		</tbody>
	</table>
</div>
</body>
</html>


#index.php


<?php
if(!empty($_GET)) {
	$fullname = $email = $password = "";

	if(isset($_GET['fullname'])) {
		$fullname = $_GET['fullname'];
	}

	if(isset($_GET['email'])) {
		$email = $_GET['email'];
	}

	if(isset($_GET['pwd'])) {
		$password = $_GET['pwd'];
	}

	echo "$fullname : $email : $password";

	die();
}
?>

<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<title>Register Form</title>
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
	<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>

	<style type="text/css">
		.form-group {
			margin-bottom: 20px;
		}
	</style>
</head>
<body>
<div class="container">
	<div class="card">
		<div class="card-header bg-info text-white">
			Register Form
		</div>
		<div class="card-body">
			<form method="get">
				<div class="form-group">
					<label>Full Name: </label>
					<input required type="text" name="fullname" class="form-control">
				</div>
				<div class="form-group">
					<label>Email: </label>
					<input required type="email" name="email" class="form-control">
				</div>
				<div class="form-group">
					<label>Password: </label>
					<input required type="password" name="pwd" class="form-control">
				</div>
				<div class="form-group">
					<button class="btn btn-info text-white" type="submit">Register</button>
					<a href="index.php"><button class="btn btn-warning" type="button">Reset</button></a>
				</div>
			</form>
		</div>
	</div>
</div>
</body>
</html>


#index1.php


<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<title>Register Form</title>
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
	<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>

	<style type="text/css">
		.form-group {
			margin-bottom: 20px;
		}
	</style>
</head>
<body>
<div class="container">
	<div class="card">
		<div class="card-header bg-info text-white">
			Register Form
		</div>
		<div class="card-body">
			<form method="get" action="detail1.php">
				<div class="form-group">
					<label>Full Name: </label>
					<input required type="text" name="fullname" class="form-control">
				</div>
				<div class="form-group">
					<label>Email: </label>
					<input required type="email" name="email" class="form-control">
				</div>
				<div class="form-group">
					<label>Password: </label>
					<input required type="password" name="pwd" class="form-control">
				</div>
				<div class="form-group">
					<button class="btn btn-info text-white" type="submit">Register</button>
					<a href="index.php"><button class="btn btn-warning" type="button">Reset</button></a>
				</div>
			</form>
		</div>
	</div>
</div>
</body>
</html>


#index2.php


<?php
if(!empty($_GET)) {
	$fullname = $email = $password = "";

	if(isset($_GET['fullname'])) {
		$fullname = $_GET['fullname'];
	}

	if(isset($_GET['email'])) {
		$email = $_GET['email'];
	}

	if(isset($_GET['pwd'])) {
		$password = $_GET['pwd'];
	}
	// echo "detail2.php?fullname=$fullname&email=$email&pwd=$password";
	header("Location: detail2.php?fullname=$fullname&email=$email&pwd=$password");

	die();
}
?>

<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<title>Register Form</title>
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
	<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>

	<style type="text/css">
		.form-group {
			margin-bottom: 20px;
		}
	</style>
</head>
<body>
<div class="container">
	<div class="card">
		<div class="card-header bg-info text-white">
			Register Form
		</div>
		<div class="card-body">
			<form method="get">
				<div class="form-group">
					<label>Full Name: </label>
					<input required type="text" name="fullname" class="form-control">
				</div>
				<div class="form-group">
					<label>Email: </label>
					<input required type="email" name="email" class="form-control">
				</div>
				<div class="form-group">
					<label>Password: </label>
					<input required type="password" name="pwd" class="form-control">
				</div>
				<div class="form-group">
					<button class="btn btn-info text-white" type="submit">Register</button>
					<a href="index.php"><button class="btn btn-warning" type="button">Reset</button></a>
				</div>
			</form>
		</div>
	</div>
</div>
</body>
</html>


#post.php


<?php
// get -> $_GET
// post -> $_POST
// get & post -> $_REQUEST
$fullname = $email = $password = "";
if(!empty($_POST)) {

	if(isset($_POST['fullname'])) {
		$fullname = $_POST['fullname'];
	}

	if(isset($_POST['email'])) {
		$email = $_POST['email'];
	}

	if(isset($_POST['pwd'])) {
		$password = $_POST['pwd'];
	}
	// echo '234234';

	//Build URL -> chuyen sang trang detail1.php -> GET => Hien thi du lieu trong bang
	// echo "$fullname : $email : $password";
	if($fullname == 'dieptv' && $password == '123') {
		header("Location: detail2.php?fullname=$fullname&email=$email&pwd=$password");

		die();
	}
}

if(!empty($_GET)) {
	if(isset($_GET['fullname'])) {
		$fullname = $_GET['fullname'];
	}

	if(isset($_GET['email'])) {
		$email = $_GET['email'];
	}

	if(isset($_GET['pwd'])) {
		$password = $_GET['pwd'];
	}
}
?>

<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<title>Register Form</title>
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
	<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>

	<style type="text/css">
		.form-group {
			margin-bottom: 20px;
		}
	</style>
</head>
<body>
<div class="container">
	<div class="card">
		<div class="card-header bg-info text-white">
			Register Form
		</div>
		<div class="card-body">
			<form method="post">
				<div class="form-group">
					<label>Full Name: </label>
					<input required type="text" name="fullname" class="form-control" value="<?=$fullname?>">
				</div>
				<div class="form-group">
					<label>Email: </label>
					<input required type="email" name="email" class="form-control" value="<?=$email?>">
				</div>
				<div class="form-group">
					<label>Password: </label>
					<input required type="password" name="pwd" class="form-control" value="<?=$password?>">
				</div>
				<div class="form-group">
					<button class="btn btn-info text-white" type="submit">Register</button>
					<button class="btn btn-warning" type="reset">Reset</button>
				</div>
			</form>
		</div>
	</div>
</div>
</body>
</html>


#readme.txt


Mở rộng yêu cầu: Khi người dùng click Register -> Hiển thị dữ liệu sang trang detail.php
	- Chuyển trực tiếp dữ liệu sang trang detail.php
	- Chuyển gián tiếp -> từ trang index.php -> Nhận dữ liệu GET -> redirect sang trang detail.php


avatar
Trần Việt Đức Anh [C2010L]
2021-05-23 10:01:35


#input.php


<!DOCTYPE html>
<html>
<head>
	<title>Register</title>
	  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
</head>
<body>
	<div class="container">
		<ul class="list-group">
		    <li class="list-group-item active">Input detail information</li>
		    <li class="list-group-item">
		   		<form method="post" action="welcome.php">
					<div class="form-group">
						<label for="usr">User Name</label>
						<input type="text" class="form-control" id="usr" name="username">
					</div>
					<div class="form-group">
						<label for="email">Email</label>
						<input type="email" class="form-control" id="email" name="email">
					</div>
					<div class="form-group">
						<label for="pwd">Password</label>
						<input type="password" class="form-control" id="pwd" name="password">
					</div>
				    <button type="submit" class="btn btn-success">Register</button>
			  </form>
		    </li>
		  </ul>
	</div>
<?php
$name = $email = $pwd = '';
if (!empty($_POST)) {
    if (isset($_POST['username'])) {
        $name = $_POST['username'];
    }
    if (isset($_POST['email'])) {
        $email = $_POST['email'];
    }
    if (isset($_POST['password'])) {
        $pwd = $_POST['password'];
    }
    // if ($name!=null&&$email!= null& $pwd!= null) {
    //     header('Location: welcome.php?username='.$name.'&email='.$email.'&password='.$pwd);
    // }
	}
?>
</body>
</html>


#welcome.php


<?php
$name = $email = $pwd = '';
if (isset($_POST['username'])) {
    $name = $_POST['username'];
}
if (isset($_POST['email'])) {
    $email = $_POST['email'];
}
if (isset($_POST['password'])) {
    $pwd = $_POST['password'];
}
?>

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>welcome</title>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css">

    <!-- jQuery library -->
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>

    <!-- Popper JS -->
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>

    <!-- Latest compiled JavaScript -->
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js"></script>
</head>

<body>
<div class="container" style="margin-top: 50px;">
    <table class="table table-bordered">
        <tbody>
        <tr>
            <td>Tên Tài Khoản</td>
            <td><?= $name ?></td>
        </tr>
        <tr>
            <td>Email</td>
            <td><?= $email ?></td>
        </tr>
        <tr>
            <td>Mật Khẩu</td>
            <td><?= $pwd?>
            <a href="input.php" style="color: rgb(255, 0, 0); background-color: rgb(255, 255, 0); font-weight: bold;">(edit)</a>
            </td>
        </tr>
        </tbody>
    </table>
</div>
</body>
</html>


avatar
Võ Như Việt [C2010L]
2021-05-06 11:43:17


#input.php
<?php

$username = $email = $password='';

if(!empty($_POST)){
		if(isset($_POST['username'])){
		$username = $_POST['username'];
	}
		if(isset($_POST['email'])){
		$email= $_POST['email'];
	}
		if(isset($_POST['password'])){
		$password = $_POST['password'];
	}

	if(!empty($username) && !empty($password)){

		header('Location: welcome.php');
	
	}	
}

?>
<!DOCTYPE html>
<html>
<head>
	<title>TEST DANG PHP</title>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
</head>
<body>
<?php
?>
	<div class="container" >	
		<div class="panel panel-primary">
					<div class="panel-heading">
					<h2>Input detailt information</h2>
					</div>
				<div class="panel-body">
					<form method="post" action="welcome.php">
					<div class="form-group">	
					 	<label>User Name</label>
					 	<input required="true" type="username" name="username" class="form-control" id="username" value="<?=$username?>">
					 </div>
					 <div class="form-group">	
						 <label>Email</label>
						 <input required="true" type="email" name="email" class="form-control" id="email" value="<?=$email?>">
					 </div>
					 <div class="form-group">	
						 <label>Password</label>
						 <input required="true" type="password" name="password" class="form-control" id="password" value="<?=$password?>">
					 </div>
					 <div>
					 	<button type="submit" class="btn btn-primary">Register</button>
					 	<button type="reset" class="btn btn-warning">Reset</button>
					 </div>
					 </form>	
				</div>
		</div>
	</div>
</body>
</html>


#welcome.php
<?php
$username = $email = $password = '';
if (isset($_POST['username'])) {
    $username = $_POST['username'];
}
if (isset($_POST['email'])) {
    $email = $_POST['email'];
}
if (isset($_POST['password'])) {
    $password = $_POST['password'];
}
?>
<!DOCTYPE html>
<html>
<head>
	<title>Thong tin nguoi dung</title>
		<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>

</head>
<body>

	<div class="container">
			<table class="table table-bordered">
				<thead>
					<tr>
						<th>Tên tài khoản</th>
						<td><?=$username?></td>
					</tr>
					<tr>
						<th>Email</th>
						<td><?=$email?></td>
					</tr>
					<tr>
						<th>Mật khẩu</th>
						<td><?=$password?><a href="input.php" class="btn btn-warning">edit</a></td>
					</tr>
				</thead>
			</table>
	</div>;


</body>
</html>


avatar
Nguyên Phấn Đông [T2008A]
2021-05-05 10:22:50


#dangky.php


<!DOCTYPE html>

<?php
require_once ('register_form.php');
?>

<html>
<head>
	<title>Object & Array in PHP</title>
	<meta charset="utf-8">
	<!-- Latest compiled and minified CSS -->
	<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">

	<!-- jQuery library -->
	<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>

	<!-- Popper JS -->
	<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>

	<!-- Latest compiled JavaScript -->
	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
		<div style="border: 1px solid grey; border-radius: 5px;">
			<div class="panel panel-primary" >
				<div class="panel-heading bg-primary">
					<h2 class="text-center">Input</h2>
				</div>
				<div class="panel-body p-5">
					<!-- get/post -->
					<form method="post">
						<div class="form-group">
						  <label for="usr">Name:</label>
						  <input required="true" type="text" class="form-control" id="usr" name="fullname">
						</div>
						<div class="form-group">
						  <label for="email">Email:</label>
						  <input required="true" type="email" class="form-control" id="email" name="email" >
						</div>
						<div class="form-group">
						  <label for="pwd">Password:</label>
						  <input required="true" type="password" class="form-control" id="pwd" name="password">
						</div>
						<button class="btn btn-success">Register</button>
					</form>
				</div>
			</div>
		</div>
	</div>
</body>
</html>


#register_form.php


<?php

// var_dump($_POST);

$fullname = $email =  $password =   '';
if (isset($_POST['fullname'])) {
	$fullname = $_POST['fullname'];
}
if (isset($_POST['email'])) {
	$email = $_POST['email'];
}
if (isset($_POST['password'])) {
	$password = $_POST['password'];
}

$a = $fullname.','.$email.','.$password.'';

if (!empty($fullname) && !empty($password)) {
	//Dang ky thanh cong
	header('Location: welcome.php?fname='.$a);
	die();
} 


#welcome.php


<!DOCTYPE html>
<html>
<head>
	<title>Welcome</title>
	<meta charset="utf-8">
	<!-- Latest compiled and minified CSS -->
	<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">

	<!-- jQuery library -->
	<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>

	<!-- Popper JS -->
	<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>

	<!-- Latest compiled JavaScript -->
	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"></script>
</head>
<body>
<?php
$arr = '';
$arrr = [];

if (isset($_GET['fname'])) {
	$arr = $_GET['fname'];
}
$count = 0;

do{
  $pos = strpos($arr, ',');
  $a = strval(substr($arr,0,$pos));
  array_push($arrr,$a);

  $arr = substr($arr,$pos+1);
  $count++;

}while ($count <= 1) ;




	echo '<table>
		<tr>
			<th>Tên</th>
			<th>'.$arrr[0].'</th>
		</tr>
		<tr>
			<th>Email</th>
			<th>'.$arrr[1].'</th>
		</tr>
		<tr>
			<th>Mật Khẩu</th>
			<th>'.$arr.'<button class="btn btn-success">edit</button></th>
		</tr>
		

	</table>';


?>
	
</body>
</html>


avatar
Nguyễn Tiến Đạt [T2008A]
2021-05-05 09:26:16


#input.php


<?php
    $username = $email = $password = ' ';
    if(isset($_GET['username'])){
        $username = $_GET['username'];
        $email = $_GET['email'];
        $password = $_GET['password'];
        if(!empty('$username') && $password == '123'){
            header('Location: welcome.php?username='.$username.'&email='.$email.'&password='.$password);
        }
    }
?>
<!doctype html>
<html lang="en">
  <head>
    <title>Input</title>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <style>
        .box{
            width: 800px;
            height: 400px;
            margin: 5px auto;
            border: 1px solid blue;
            /* padding: 5px; */
            border-radius: 5px;
        }
        .header{
            width: 100%;
            background-color: #1c74dfe8;
            color: #fff;
            padding: 5px;
            margin-top: -1px;
        }
        form{
            margin: 10px;
        }
    </style>
    <!-- Bootstrap CSS -->
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
  </head>
  <body>
    <div class="box">
        <div class="header">
            <span>Input detail information</span>
        </div>
        <form method="get">
            <div class="form-group">
              <label for="">User Name</label>
              <input type="text" name="username" id="" class="form-control" placeholder="">
              <label for="">Email</label>
              <input type="email" name="email" id="" class="form-control" placeholder="">
              <label for="">Password</label>
              <input type="password" name="password" id="" class="form-control" placeholder="">
            </div>
            <button name="" id="" class="btn btn-success" btn-lg btn-block">Register</button>
        </form>
    </div>
    <!-- Optional JavaScript -->
    <!-- jQuery first, then Popper.js, then Bootstrap JS -->
    <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
  </body>
</html>


#welcome.php


<?php
    $username = $email = $password = ' ';
    if(isset($_GET['username'])){
        $username = $_GET['username'];
        $email = $_GET['email'];
        $password = $_GET['password'];
    }
?>
<!doctype html>
<html lang="en">
  <head>
    <title>Welcome</title>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <style>
        .container{
            margin-top: 50px;
        }
        .first-col{
            width: 35%;
        }
        a{
            background-color: yellow !important;
            color: red !important;
            text-decoration: none !important;
        }
    </style>
    <!-- Bootstrap CSS -->
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
  </head>
  <body>
    <div class="container">
        <table class="table table-bordered">
                <tr>
                    <td class="first-col"">Tên tài khoản</td>
                    <td><?=$username?></td>
                </tr>
                <tr>
                    <td>Email</td>
                    <td><?=$email?></td>
                </tr>
                <tr>
                    <td>Mật khẩu</td>
                    <td><?=$password?> <a href="input.php">(edit)</a></td>
                </tr>
        </table>
    </div>
    <!-- Optional JavaScript -->
    <!-- jQuery first, then Popper.js, then Bootstrap JS -->
    <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
  </body>
</html>


avatar
Đào Mạnh Dũng [C2010L]
2021-05-04 13:58:07


#input.php


<!DOCTYPE html>
<html>
<head>
	<title>Register</title>
	  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
</head>
<body>
	<div class="container">
		<ul class="list-group">
		    <li class="list-group-item active">input information</li>
		    <li class="list-group-item">
		    			 <form method="post" action="welcome.php">
						    <div class="form-group">
						      <label for="usr">Name:</label>
						      <input type="text" class="form-control" id="usr" name="username">
						    </div>
						    <div class="form-group">
						      <label for="email">Email:</label>
						      <input type="email" class="form-control" id="email" name="email">
						    </div>
						    <div class="form-group">
						      <label for="pwd">Password:</label>
						      <input type="password" class="form-control" id="pwd" name="password">
						    </div>
						    <button type="submit" class="btn btn-success">Register</button>
						  </form>
		    </li>
		  </ul>
	</div>
<?php
$name = $email = $pass = '';
if (!empty($_POST)) {
    if (isset($_POST['username'])) {
        $name = $_POST['username'];
    }
    if (isset($_POST['email'])) {
        $email = $_POST['email'];
    }
    if (isset($_POST['password'])) {
        $pass = $_POST['password'];
    }
    // if ($name!=null&&$email!= null& $pass!= null) {
    //     header('Location: welcome.php?username='.$name.'&email='.$email.'&password='.$pass);
    // }
}
?>
</body>
</html>


#welcome.php


<?php
$name = $email = $pass = '';
if (isset($_POST['username'])) {
    $name = $_POST['username'];
}
if (isset($_POST['email'])) {
    $email = $_POST['email'];
}
if (isset($_POST['password'])) {
    $pass = $_POST['password'];
}
?>

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>welcome</title>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css">

    <!-- jQuery library -->
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>

    <!-- Popper JS -->
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>

    <!-- Latest compiled JavaScript -->
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js"></script>
</head>

<body>
<div class="container" style="margin-top: 50px;">
    <table class="table table-bordered"><tbody><tr><td>Tên Tài Khoản</td><td><?= $name ?></td></tr><tr><td>Email</td><td><?= $email ?></td></tr><tr><td>Mật Khẩu</td><td><?= $pass ?><a href="input.php" style="color: rgb(255, 0, 0); background-color: rgb(255, 255, 0); font-weight: bold;">(edit)</a></td></tr></tbody></table>
</div>

</body>

</html>


avatar
Trần Mạnh Dũng [T1907A]
2020-06-22 13:04:50



<?php
    $Username = $Email = $Password = '';

    
    	if(isset($_POST['username'])){
    		$Username = $_POST['username'];
    	}
    	if(isset($_POST['email'])){
    		$Email = $_POST['email'];
    	}
    	if(isset($_POST['password'])){
    		$Password = $_POST['password'];
    	}
    
?>

<!DOCTYPE html>
<html>
<head>
	<title>To be con to niu</title>
	<style type="text/css">
		table ,td, th{
			border: 1px solid black;
			border-collapse: collapse;
			background: yellow;
		}
		td , th{
			padding: 10px;
		}
	</style>
</head>
<body>
	<table>
		<tr>
			<td>Tên Tài Khoản : </td>
            <th><?=$Username?></th>
            
		</tr>
		<tr>
			<td>Email : </td>
			<th><?=$Email?></th>
		</tr>
		<tr>
			<td>Mật khẩu : </td>
			<th><?=$Password?><a href="input.php" style="color: red">(EDIT)</a></th>
		</tr>
	</table>
    

</body>
</html>



<?php
    $Username = $Email = $Password = '';

    
    	if(isset($_POST['username'])){
    		$Username = $_POST['username'];
    	}
    	if(isset($_POST['email'])){
    		$Email = $_POST['email'];
    	}
    	if(isset($_POST['password'])){
    		$Password = $_POST['password'];
    	}
    
?>
<!DOCTYPE html>
<html>
<head>
	<title>Input Detailt Information </title>
	<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js"></script>
</head>
<body>
	<div class="container">
		<div class="panel-heading">
			<h2 style="color: blue">Input Detailt Information</h2>
		</div>
		<div class="panle-body">
			<form method="post" action="welcome.php">
				<div class="form-group">
					<label for="usr">User Name : </label>
                    <input required="true" type="text" class="form-control" id="username" name="username" value="<?=$Username?>" > 
				</div>
				<div class="form-group">
					<label for="email">Email :</label>
					<input required="true" type="email" class="form-control" id="email" name="email" value="<?=$Email?>">
				</div>
				<div class="form-group">
					<label for="password">Password :</label>
					<input required="password" type="password" class="form-control" id="password"  name="password">
				</div>
				<button class="btn btn-success">Register</button>
			</form>
		</div>
	</div>

</body>
</html>


avatar
Đỗ Văn Huấn [T1907A]
2020-06-17 01:36:59



<?php
$name = $email = $pass = '';
if (isset($_GET['username'])) {
    $name = $_GET['username'];
}
if (isset($_GET['email'])) {
    $email = $_GET['email'];
}
if (isset($_GET['password'])) {
    $pass = $_GET['password'];
}
// if ($name != null && $email != null && $pass != null) {
//     header('Location: input.php?username=' . $name . '&email=' . $email . '&password=' . $pass);
// }
?>

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css">

    <!-- jQuery library -->
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>

    <!-- Popper JS -->
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>

    <!-- Latest compiled JavaScript -->
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js"></script>
</head>

<body>


    <div class="container">
        <table class="table table-bordered">
            <thead>
                <tr>
                    <th>Username</th>
                    <th>Email</th>
                    <th>Password</th>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td> <?= $name ?> </td>
                    <td><?= $email ?></td>
                    <td><?= $pass ?> <a  href="input.php" style="color: red;"> edit</a> </td>
                </tr>

            </tbody>
        </table>
    </div>
</body>

</html>



<?php
$name = $email = $pass = '';
if (!empty($_GET)) {
    if (isset($_GET['username'])) {
        $name = $_GET['username'];
    }
    if (isset($_GET['email'])) {
        $email = $_GET['email'];
    }
    if (isset($_GET['password'])) {
        $pass = $_GET['password'];
    }
    if ($name!=null&&$email!= null& $pass!= null) {
        header('Location: welcome.php?username='.$name.'&email='.$email.'&password='.$pass);
    }
}


?>
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <!-- Latest compiled and minified CSS -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css">

    <!-- jQuery library -->
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>

    <!-- Popper JS -->
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>

    <!-- Latest compiled JavaScript -->
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js"></script>
    <title>Document</title>
    <style>
        .container {
            border: 1px solid red;
            margin-top: 30px;
            border-radius: 10px;
        }

        .btn {
            width: 100px;
            background-color: rgb(111, 214, 216);
            background: red;
        }
    </style>
</head>

<body>
    <div class="container">

        <!-- method: get => $_GET => du lieu se duoc hien len url -->
        <!-- method: post => $_POST => du lieu se duoc an  -->

        <form method="$_GET">
            <div class="form-group">
                <label for="user">Username : </label>
                <input type="text" name="username" class="form-control" placeholder="Enter User name" id="user"
                 value="<?=$name?>">
            </div>
            <div class="form-group">
                <label for="email">Email:</label>
                <input type="email" name="email" class="form-control" placeholder="Enter email" id="email" 
                value="<?=$email?>">
            </div>
            <div class="form-group">
                <label for="pwd">Password:</label>
                <input type="password" name="password" class="form-control" placeholder="Enter password" id="pwd"
                value="<?=$pass?>">
            </div>
            <button type="submit" class="btn btn-primary">Submit</button>
        </form>
    </div>
</body>

</html>


avatar
hoangduyminh [T1907A]
2020-06-12 03:05:28



<?php 
$Name = $Email = $Password = '';
if (!empty($_GET)) {
  if (isset($_GET['fullname'])) {
    $Name = $_GET['fullname'];
  }
  if (isset($_GET['email'])) {
    $Email = $_GET['email'];
  }
  if (isset($_GET['password'])) {
    $Password = $_GET['password'];
  }
}
 ?>
<!DOCTYPE html>
<html>
<head>
	<title></title>
</head>
<body>
   <table>
   	<tr>
   		<th>Ho Va Ten</th>
   		<th>Email</th>
   		<th> Password</th>
   	</tr>
   	<tr>
   		<td><?= $Name?></td>
   		<td><?= $Email?></td>
   		<td><?= $Password?><a href= "index.php" style="color: red">(edit)</a></td>
   	</tr>
   </table>
</body>
</html>



<?php 
$Name = $Email = $Password = '';
if (!empty($_POST)) {
	$Name = $_POST['fullname'];
	$Email = $_POST['email'];
	$Password = $_POST['password'];
	if($Password == '123'  && $Name == 'Hoang Duy Minh')
        	{

        		header('Location: welcome.php'.'?fullname='.$Name .'&email='.$Email.'&password='.$Password);

        	}
}

 ?>
	<!DOCTYPE html>
	<html>
	<head>
		<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">

		<!-- jQuery library -->
		<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>

		<!-- Popper JS -->
		<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
		<title></title>
	</head>
	<body>
	  <form method="POST" action="">
	  	<div class="panel-body">
	  	<div class="form-group">
			<label for="usr"> User Name:</label>
			<input required="true" type="text" class="form-control" id="usr" name ="fullname">
		</div>
		<div class="form-group">
			<label for="usr"> Email:</label>
			<input required="true" type="text" class="form-control" id="usr" name = "email">
		</div>
		<div class="form-group">
			<label for="usr"> Password:</label>
			<input required="true" type="password" class="form-control" id="usr" name ="password">
		</div>
		<button class="btn btn-success">Regitser</button>
	  </div>
	  </form>
	</body>
	</html>


avatar
thienphu [T1907A]
2020-06-12 03:01:56


#formDangKi.php


<!DOCTYPE html>
<html>
<head>
	<title>Register</title>
	<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
	  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
	  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
</head>
<body>

	<div class="container">
		
		<form action="wellcome.php" method="POST">
			 <div class="form-group">
    			<label for="UserName">UserName</label>
    			<input type="UserName" class="form-control" name="UserName">
  			</div>
			 <div class="form-group">
    			<label for="email">Email</label>
    			<input type="email" class="form-control" name="email">
  			</div>
  			<div class="form-group">
   			 <label for="pwd">Password:</label>
    		<input type="password" class="form-control" name="password">
		 	</div>
		 	<button type="submit" class="btn btn-primary">Register	</button>
		  	
		</form>
	</div>
</body>
</html>


#wellcome.php


<!DOCTYPE html>
<?php
$username=$email =$pass ='';
	if(!empty($_POST)){

		if(isset($_POST['UserName'])){
			$username = $_POST['UserName'];
		}
		if(isset($_POST['email'])){
			$email = $_POST['email'];
		}
		if(isset($_POST['password'])){
			$pass = $_POST['password'];
		}

	}

	
?>
<html>
<head>
	<title></title>
	<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
	  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
	  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
</head>
<body>
	<table class="table table-bordered">
    <thead>
      <tr>
        <th>UserName</th>
        <th><?=$username?></th>
      </tr>

       <tr>
        <th>Email</th>
        <th><?=$email?></th>
      </tr>

       <tr>
        <th>PassWord</th>
        <th><?=$pass?><a href="formDangKi.php" style="color: red" >(Edit)</a></th>
      </tr>
    </thead>
</body>
</html>