Skip to content

Commit b034612

Browse files
committed
module 7
1 parent 0b60635 commit b034612

File tree

4 files changed

+122
-0
lines changed

4 files changed

+122
-0
lines changed

form_example.php

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<html lang="en">
2+
<head>
3+
<meta charset="UTF-8">
4+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<title>Form Example</title>
7+
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
8+
</head>
9+
<body>
10+
<div>
11+
12+
<div class="row">
13+
<div class="col-md-4">
14+
15+
</div>
16+
<div class="col-md-4 mt-4 pt-5">
17+
<h1 class="mb-4">User registration from</h1>
18+
19+
<form action="./form_example_submit.php" method="POST">
20+
<div class="mb-3">
21+
<label for="exampleInputEmail1" class="form-label">Email address</label>
22+
<input type="email" class="form-control" id="exampleInputEmail1" aria-describedby="emailHelp" name="email" required>
23+
24+
</div>
25+
<div class="mb-3">
26+
<label for="fullName" class="form-label">Name</label>
27+
<input type="text" class="form-control" id="fullName" aria-describedby="nameHelp" name="fullName" required>
28+
29+
</div>
30+
31+
<div class="mb-3">
32+
<label for="dob" class="form-label">Date of birth</label>
33+
<input type="date" class="form-control" id="dob" aria-describedby="nameHelp" name="dob" required>
34+
35+
</div>
36+
<div class="mb-3">
37+
<label for="exampleInputPassword1" class="form-label">Password</label>
38+
<input type="password" class="form-control" id="exampleInputPassword1" name="password" required>
39+
</div>
40+
41+
<button type="submit" class="btn btn-primary">Submit</button>
42+
</form>
43+
</div>
44+
<div class="col-md-4">
45+
46+
</div>
47+
48+
</div>
49+
</div>
50+
51+
52+
53+
54+
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>
55+
</body>
56+
</html>

form_example_submit.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
$email = $_POST['email'];
4+
$fullName = $_POST['fullName'];
5+
$dob = $_POST['dob'];
6+
$password = $_POST['password'];
7+
8+
9+
10+
$user_collection = [];
11+
$user_collection['email'] = $email;
12+
$user_collection['full_name'] = $fullName;
13+
$user_collection['date_of_birth'] = $dob;
14+
$user_collection['password'] = hash('md5',$password);
15+
16+
print_r($user_collection);
17+
18+
?>

form_submit_validation.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
$userName = $_POST['user_name'];
4+
$password = $_POST['password'];
5+
6+
if($userName != ""){
7+
if ($password != "") {
8+
# code...
9+
print_r("Username is $userName and password is $password");
10+
}else{
11+
echo "Please fill password!!";
12+
}
13+
14+
}else{
15+
echo "Please fill username!!";
16+
}
17+
18+
19+
20+
//form validation
21+
// frontend and backend
22+
23+
24+
?>
25+

form_validation.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<html lang="en">
2+
<head>
3+
<meta charset="UTF-8">
4+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<title>Form Validation</title>
7+
</head>
8+
<body>
9+
<form action="./form_submit_validation.php" method="POST">
10+
<label>
11+
User name
12+
</label>
13+
<input type="text" name="user_name" value="" >
14+
15+
<label>
16+
Password
17+
</label>
18+
<input type="password" name="password" value="" >
19+
20+
<input type="submit" value="submit">
21+
</form>
22+
</body>
23+
</html>

0 commit comments

Comments
 (0)