This commit is contained in:
louiscklaw
2025-02-01 01:58:47 +08:00
parent b3da7aaef5
commit 04dbefcbaf
1259 changed files with 280657 additions and 0 deletions

View File

@@ -0,0 +1,37 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Lab03 Task1</title>
</head>
<style>
.row{
margin-top: 10px;
margin-bottom: 10px;
}
</style>
<body>
<form action="Lab03_Task1.php" method="post">
<div class="row">
Name: <input type="text" name="name" id="name" value="">
</div>
<div class="row">
Graduate Year: <input type="text" name="year" id="year">
</div>
<div class="row">
<div>Alumi</div>
<input type="radio" name="alumi" id="alumi" value="Yes" checked> Yes<br>
<input type="radio" name="alumi" id="alumi" value="No"> No
</div>
<div class="row">
<div>Comments</div>
<textarea name="comments" id="comments" cols="30" rows="10"></textarea>
</div>
<input type="submit" value="Submit">
</form>
</body>
</html>

View File

@@ -0,0 +1,42 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Lab03 Task1</title>
</head>
<body>
<?php
extract($_POST);
$isVaild = true;
if(!isset($name) || strlen(trim($name)) == 0){
echo "Name field is missing <br />";
$isVaild = false;
}
if(!isset($year) || strlen(trim($year)) == 0){
echo "Graduate Year field is missing <br />";
$isVaild = false;
}
if(!isset($comments) || strlen(trim($comments)) == 0){
echo "Comment field is missing <br />";
$isVaild = false;
}
if($isVaild){
echo "Name: $name<br>";
echo "Graduate Year: $year<br>";
echo "Alumi: $alumi<br>";
echo "Comments: $comments";
}
?>
</body>
</html>

View File

@@ -0,0 +1,31 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Lab03 Task2</title>
</head>
<style>
.row {
margin-top: 10px;
margin-bottom: 10px;
}
</style>
<body>
<form action="Lab03_Task2.php" method="post">
<div class="row">
Calculate Two Numbers Function
</div>
<div class="row">
Enter first number: <input type="number" name="first" id="first"/>
</div>
<div class="row">
Enter second number: <input type="number" name="second" id="second">
</div>
<div class="row">
<input type="submit" value="Calculate">
</div>
</form>
</body>
</html>

View File

@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Lab03 Task2</title>
</head>
<body>
<h1>Calculate Two Numbers Function</h1>
The total of two numbers <?php echo "$_POST[first]"?> and <?php echo "$_POST[second]"?> is <?php echo $_POST["first"]+$_POST["second"]?>
</body>
</html>

View File

@@ -0,0 +1,31 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Lab03 Task3</title>
</head>
<style>
.row {
margin-top: 10px;
margin-bottom: 10px;
}
</style>
<body>
<form action="Lab03_Task3.php" method="post">
<div class="row">
<h1>User Name and Year of Brith</h1>
</div>
<div class="row">
First Name: <input type="text" name="firstName" id="firstName"><br>
Last Name: <input type="text" name="lastName" id="lastName"><br>
Year of Birth: <input type="text" name="yearOfBirth" id="yearOfBirth">
</div>
<div class="row">
<input type="submit" value="Send">
<input type="reset" value="Cancel">
</div>
</form>
</body>
</html>

View File

@@ -0,0 +1,49 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Lab03 Task3</title>
</head>
<body>
<?php
extract($_POST);
$isVaild = true;
$errMes = "";
if (!isset($firstName) || strlen(trim($firstName)) == 0) {
$errMes .= "first name is invalid! ";
$isVaild = false;
}
if ($isVaild && (!isset($lastName) || strlen(trim($lastName)) == 0)) {
$errMes .= "last name is invalid!";
$isVaild = false;
}
if ($isVaild && (!isset($yearOfBirth) || strlen(trim($yearOfBirth)) == 0)) {
$errMes .= "year of birth is invalid!";
$isVaild = false;
}
if (!$isVaild) {
echo "<h3>Hello, $errMes</h3>";
echo "<p>Please re-enter the information</p>";
echo '<p><a href="Lab03_Task3.html">Go back to form</a></p>';
} else {
$age = date('Y') - $yearOfBirth;
if ($age >= 18){
echo "<h3>Welcome! $firstName $lastName</h3>";
echo "<h3>You are now $age years old, so you can fill this form.</h3>";
}else{
echo "<h3>Sorry: Your age is: $age.</h3>";
echo "<h3>You should be over 18 to fill this form</h3>";
}
}
?>
</body>
</html>