lernen prog-p added (nicht alles) 1/2
This commit is contained in:
16
progp/lernen/übung_ka1/raten.html
Normal file
16
progp/lernen/übung_ka1/raten.html
Normal file
@@ -0,0 +1,16 @@
|
||||
<!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>
|
||||
<h1>Rate die Zahl!</h1>
|
||||
<form action="raten.html">
|
||||
<label for="zahl">Zahl:</label>
|
||||
<input type="number" name="input_zahl" id="zahl">
|
||||
<button type="submit">Raten</button>
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
||||
35
progp/lernen/übung_ka1/raten.php
Normal file
35
progp/lernen/übung_ka1/raten.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<!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>
|
||||
<h1>Rate die Zahl!</h1>
|
||||
<form action="raten.php">
|
||||
<label for="id_zahl">Zahl:</label>
|
||||
<input type="number" name="name_zahl" id="id_zahl">
|
||||
<button type="submit">Raten</button>
|
||||
</form>
|
||||
<?php
|
||||
$zahl = $_REQUEST['input_zahl'];
|
||||
$random = rand(1, 100);
|
||||
if ($zahl == $random) {
|
||||
echo "<p>Richtig!</p>";
|
||||
if ($zahl % 2 == 0) {
|
||||
echo "<p>Die Zahl ist gerade!</p>";
|
||||
} else {
|
||||
echo "<p>Die Zahl ist ungerade!</p>";
|
||||
}
|
||||
} else {
|
||||
echo "Falsch!";
|
||||
if ($zahl % 2 == 0) {
|
||||
echo "<p>Die Zahl ist gerade!</p>";
|
||||
} else {
|
||||
echo "<p>Die Zahl ist ungerade!</p>";
|
||||
}
|
||||
}
|
||||
?>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user