![]() |
![]() ![]() |
![]() |
![]()
Post
#1
|
|
Grupa: Zarejestrowani Postów: 4 Pomógł: 0 Dołączył: 14.04.2017 Ostrzeżenie: (10%) ![]() ![]() |
<!DOCTYPE html>
<html> <head> <title>Formularz w HTML</title> <meta charset=utf-8/> <style> <!-- https://pastebin.com/07As6MFA --> <!-- https://pastebin.com/sbU5Kn6S --> body { border:2px solid red; } form { width:80%; margin:auto auto; padding:20px; } label { padding: 10px; display:block; overflow:auto; } label input { width:80%; float: right; } .center { display:block; margin: auto auto; } </style> </head> <body> <!-- Formularz z 2 polami typu input + przycisk SUBMIT --> <!-- Metoda: - GET - dane przesyłane przez adres URL - POST - dane przesyłane przez nagłówki HTTP --> <?php function czy_przekazane_dane_ok() { $jestImie = isset($_GET['imie']); $jestNazwisko = isset($_GET['nazwisko']); return $jestImie && $jestNazwisko; } function wyswietl_formularz() { global $formularz; echo $formularz; } function wyswietl_powitanie() { $imie = $_GET['imie']; $nazwisko = $_GET['nazwisko']; $kolor = $_GET['kolor']; $wykszalcenie = $_GET['wyksztalcenie']; $mail = $_GET['mail']; $data = $intCurrentDateStamp = time(); $intBirthStamp = $_GET['date']; $intAge = $intCurrentDateStamp - $intBirthStamp; $div =<<<BLOK <div style='color:$kolor'> <p>Twoje imie: <b>$imie</b></p> <p>Twoje nazwisko: <b>$nazwisko</b></p> <p>Twoje wykszczlcenie: <b>$wykszalcenie</b></p> <p>Twoj email : <b>$mail</b></p> <p>Masz lat : <b>$intAge</b></p> </div> BLOK; echo $div; } $formularz = <<<FORM <form action="#" method="GET"> <!-- Uwaga: atrybut NAME jest wymagany ![]() --> <label> Twoje imie: <input type=text name="imie" placeholder="Wpisz imie"/> </label> <label> Twoje nazwisko: <input type=text name="nazwisko" placeholder="Wpisz nazwisko"/> </label> <label> Ulubiony kolor: <input type=color name="kolor" placeholder="Wpisz nazwisko"/> </label> <label>Podstawowe <input type=radio name="wyksztalcenie" value="Podstawowe"> </label> <label>Średnie <input type=radio name="wyksztalcenie" value="Średnie"> </label> <label>Wyższe <input type=radio name="wyksztalcenie" value="Wyższe"> </label> <input class=center type="submit" value="Wyślij formularz"/> <label> Twój Adres e-mail <input type=text name="mail" placeholder="wpisz email"/> </label> <label> Twoja data urodzenia <input id="date" type="date" name="data" /> </label> </form> FORM; if(czy_przekazane_dane_ok()) { wyswietl_powitanie(); } else { wyswietl_formularz(); } ?> </div> </body> </html> |
|
|
![]()
Post
#2
|
|
Grupa: Zarejestrowani Postów: 361 Pomógł: 12 Dołączył: 9.01.2010 Ostrzeżenie: (10%) ![]() ![]() |
Korzystaj ze znaczników. Bo teraz to WIELKI ŚMIETNIK
|
|
|
![]() ![]() |
![]() |
Aktualny czas: 22.08.2025 - 09:52 |