add m2 1/2

This commit is contained in:
vadym Novoselskyi 2024-08-26 14:17:08 +02:00
parent b703505447
commit 546c1a36a8
12 changed files with 226 additions and 8 deletions

View File

@ -1,6 +1,11 @@
<!doctype html>
<!DOCTYPE html>
<head>
<html>
<head lang="sv"></head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</html>
<body>
<h1>Matematik-test</h1>
<form action="evaluate.php" method="post">

View File

@ -28,7 +28,9 @@
else if($points >= 3) $result = "Godkänd";
else $result = "Läs på mer och försök igen";
//test
#test
/*test */
echo "<p>$result, poäng - $points</p>"
?>
</body>

View File

@ -0,0 +1,15 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Result</title>
</head>
<body>
<?php
$name = strip_tags($_GET['name'], "<br>");
$age = strip_tags($_GET['age'], "<br>");
echo "<p>Name - $name; Age - $age</p>"
?>
</body>
</html>

View File

@ -0,0 +1,24 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>M2 01</title>
</head>
<body>
<h1>Send data via url</h1>
<form action="handle.php" method="get">
<fieldset>
<legend>Person</legend>
<label>Name</label>
<input type="text" name="name">
<label>Age</label>
<input type="number" name="age">
<br>
<input type="submit" value="Submit">
</fieldset>
</form>
</body>
</html>

View File

@ -0,0 +1,22 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>M2 02</title>
</head>
<body>
<?php
for($i = 1; $i <= 5.0; $i += 0.1) {
echo " $i, ";
}
$i = 1;
echo "<br>";
while($i <= 5.0) {
echo " $i, ";
$i += 0.1;
}
?>
</body>
</html>

View File

@ -0,0 +1,20 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>M2 02</title>
</head>
<body>
<?php
$page["head"] = "<h1>Välkommen</h1>";
$page["main"] = "<p>Detta är innehållet på min sida</p>";
$page["footer"] = "<hr><p>Min sidfoot</p>";
foreach($page as $value) {
echo $value;
}
?>
</body>
</html>

View File

@ -0,0 +1,19 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>M2 02</title>
</head>
<body>
<?php
include("math.php");
$num1 = 6;
$num2 = 3;
echo "Number 1 = $num1; Number 2 = $num2 <br>";
echo "Sum: " . sum($num1, $num2) . ". Difference: " .substract($num1, $num2) . ". Product: " . multiply($num1, $num2) . ". Division: " . divide($num1, $num2);
?>
</body>
</html>

18
www/public/M2/04/math.php Normal file
View File

@ -0,0 +1,18 @@
<?php
function sum($num1, $num2) {
return $num1 + $num2;
}
function substract($num1, $num2) {
return $num1 - $num2;
}
function multiply($num1, $num2) {
return $num1 * $num2;
}
function divide($num1, $num2) {
return $num1 / $num2;
}
?>

View File

@ -0,0 +1,35 @@
<?php
class Person {
private $name;
private $surname;
private $username;
private $password;
public function __construct($name, $surname, $username, $password) {
$this->name = $name;
$this->surname = $surname;
$this->username = $username;
$this->password = $password;
}
public function getName() {
return $this->name;
}
public function getSurname() {
return $this->surname;
}
public function getUsername() {
return $this->username;
}
public function getPassword() {
return $this->password;
}
public function setPassword($password) {
$this->password = $password;
}
}

View File

@ -0,0 +1,34 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>M2 05</title>
</head>
<body>
<?php
if(isset($_POST["name"])) $name = $_POST["name"];
if(isset($_POST["surname"])) $surname = $_POST["surname"];
if(isset($_POST["username"])) $username = $_POST["username"];
if(isset($_POST["password"])) $password = $_POST["password"];
$name = cleanData($name);
$surname = cleanData($surname);
$username = cleanData($username);
$password = cleanData($password);
echo "Name: " . $name . "<br>";
echo "Surname: " . $surname . "<br>";
echo "Username: " . $username . "<br>";
echo "Password: " . $password . "<br>";
function cleanData($data) {
$data = strip_tags($data);
$data = htmlspecialchars($data);
$data = trim($data);
$data = stripslashes($data);
return $data;
}
?>
</body>
</html>

View File

@ -0,0 +1,24 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>M2 02</title>
</head>
<body>
<form action="handle.php" method="post">
<fieldset >
<legend>Login</legend>
<label>Your name: </label>
<input type="text" name="name">
<label>Your surname: </label>
<input type="text" name="surname"> <br> <br>
<label>Your username: </label>
<input type="text" name="username">
<label>Your password: </label>
<input type="text" name="password">
<input type="submit" value="Submit">
</fieldset>
</form>
</body>
</html>

View File

@ -1,7 +1,7 @@
<footer style="border: 2px #000000 solid; border-radius: 1%;">
<span style="display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; justify-items: center; text-decoration: none;">
<a href="./index.php">Index</a>
<a href="./M0/01/index.html">M0</a>
<a href="./M1/index.php">M1</a>
<a href="./M0/01/index.php">M0</a>
<a href="./M1/01/index.php">M1</a>
<a href="./M2/01/index.php">M2</a>
</span>
</footer>