Browse Source

01maturita

master
Jakub Škrabánek 2 years ago
parent
commit
5d1de3f09f
  1. 19
      php_procviceni_predMaturitou/01/formular.php
  2. 31
      php_procviceni_predMaturitou/01/index.php
  3. 3
      php_procviceni_predMaturitou/01/info.php
  4. 1
      php_procviceni_predMaturitou/01/text.txt

19
php_procviceni_predMaturitou/01/formular.php

@ -0,0 +1,19 @@
<?php
if (isset($_GET["name"])) { //ověření existující $_GET proměnné
$name = $_GET["name"];
} else {
$name = "ERROR";
}
//echo $name;
//otevřeme soubor a přečteme obsah
$myfile = fopen("text.txt", "a") or die("Nelze otevřít");
//nalezneme v proměné nové řádky a nahradíme je <br>
$msg = "\n".$name; //vynucení nového řádku
$msg = str_replace("\n","<br>",$msg);
//zapíšeme a uložíme
fwrite($myfile,$msg);
fclose($myfile);
//přesměrování
header("Location: /");
?>

31
php_procviceni_predMaturitou/01/index.php

@ -0,0 +1,31 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<?php
$promena = "NEJAKY TEXT"; //proměnná
for ($i=0; $i < 4; $i++) {
echo "<p>".$i.". ".$promena."</p>"; // můžu vládat HTML kod
}
?>
<!-- Formulář -->
<form action="formular.php" method="get">
<input type="text" name="name" id="name"> <br>
<input type="submit" value="Odeslat formular">
</form>
<!-- vypis formulare ze souboru -->
<?php
$fname = "text.txt";
$myfile = fopen($fname,"r");
echo fread($myfile,filesize($fname));
fclose($myfile);
?>
</body>
</html>

3
php_procviceni_predMaturitou/01/info.php

@ -0,0 +1,3 @@
<?php
phpinfo();
?>

1
php_procviceni_predMaturitou/01/text.txt

@ -0,0 +1 @@
<br>les<br>pes<br>kekx<br>wrum
Loading…
Cancel
Save