diff options
author | Mateja <mail@matejamaric.com> | 2020-09-28 19:25:40 +0200 |
---|---|---|
committer | Mateja <mail@matejamaric.com> | 2020-09-28 19:25:40 +0200 |
commit | 524fdc3a0ea3960823472e7e3f948b0cdd2003ef (patch) | |
tree | 8607dceb649b6d92b804779c77c88b2dc45c3ea0 | |
parent | 00fda2f0dfdaa1129949f0fa116cfaeff23ab486 (diff) | |
download | old-php-yota-524fdc3a0ea3960823472e7e3f948b0cdd2003ef.tar.gz old-php-yota-524fdc3a0ea3960823472e7e3f948b0cdd2003ef.zip |
checkboxes to array
-rw-r--r-- | reservation.php | 74 |
1 files changed, 37 insertions, 37 deletions
diff --git a/reservation.php b/reservation.php index 84949c5..f070d1c 100644 --- a/reservation.php +++ b/reservation.php @@ -26,22 +26,22 @@ session_start(); <main> <?php if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST['fname']) && isset($_POST['lname']) && isset($_POST['age'])) { - $user = "yota_user"; - $password = "leex3EThieK0ieLaiVaicaifef5eecei"; - $database = "yota_call_db"; - $table = "activities"; - try { - $conn = new PDO("mysql:host=localhost;dbname=$database", $user, $password); - $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); - $stmt = $conn->prepare("INSERT INTO activities (name, surname, age) VALUES (:name, :surname, :age)"); - $stmt->bindParam(':name', $_POST['fname']); - $stmt->bindParam(':surname', $_POST['lname']); - $stmt->bindParam(':age', $_POST['age']); - $stmt->execute(); - echo "<p>Data inserted.</p>"; - } catch (PDOException $e) { - echo "<p>Error!: " . $e->getMessage() . "</p>"; - } + $user = "yota_user"; + $password = "leex3EThieK0ieLaiVaicaifef5eecei"; + $database = "yota_call_db"; + $table = "activities"; + try { + $conn = new PDO("mysql:host=localhost;dbname=$database", $user, $password); + $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + $stmt = $conn->prepare("INSERT INTO activities (name, surname, age) VALUES (:name, :surname, :age)"); + $stmt->bindParam(':name', $_POST['fname']); + $stmt->bindParam(':surname', $_POST['lname']); + $stmt->bindParam(':age', $_POST['age']); + $stmt->execute(); + echo "<p>Data inserted.</p>"; + } catch (PDOException $e) { + echo "<p>Error!: " . $e->getMessage() . "</p>"; + } } ?> <form method="post"> @@ -74,46 +74,46 @@ if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST['fname']) && isset($_PO <fieldset> <legend>I will be active on bands:</legend> - <input type="checkbox" id="cb1" name="cb1" value="1.8 MHz"> + <input type="checkbox" id="cb1" name="freqs[]" value="1.8 MHz"> <label for="cb1">1.8 MHz</label><br> - <input type="checkbox" id="cb2" name="cb2" value="3.5 MHz"> + <input type="checkbox" id="cb2" name="freqs[]" value="3.5 MHz"> <label for="cb2">3.5 MHz</label><br> - <input type="checkbox" id="cb3" name="cb3" value="7 MHz"> + <input type="checkbox" id="cb3" name="freqs[]" value="7 MHz"> <label for="cb3">7 MHz</label><br> - <input type="checkbox" id="cb4" name="cb4" value="10 MHz"> + <input type="checkbox" id="cb4" name="freqs[]" value="10 MHz"> <label for="cb4">10 MHz</label><br> - <input type="checkbox" id="cb5" name="cb5" value="14 MHz"> + <input type="checkbox" id="cb5" name="freqs[]" value="14 MHz"> <label for="cb5">14 MHz</label><br> - <input type="checkbox" id="cb6" name="cb6" value="18 MHz"> + <input type="checkbox" id="cb6" name="freqs[]" value="18 MHz"> <label for="cb6">18 MHz</label><br> - <input type="checkbox" id="cb7" name="cb7" value="21 MHz"> + <input type="checkbox" id="cb7" name="freqs[]" value="21 MHz"> <label for="cb7">21 MHz</label><br> - <input type="checkbox" id="cb8" name="cb8" value="24 MHz"> + <input type="checkbox" id="cb8" name="freqs[]" value="24 MHz"> <label for="cb8">24 MHz</label><br> - <input type="checkbox" id="cb9" name="cb9" value="28 MHz"> + <input type="checkbox" id="cb9" name="freqs[]" value="28 MHz"> <label for="cb9">28 MHz</label><br> - <input type="checkbox" id="cb10" name="cb10" value="50 MHz"> + <input type="checkbox" id="cb10" name="freqs[]" value="50 MHz"> <label for="cb10">50 MHz</label><br> - <input type="checkbox" id="cb11" name="cb11" value="144 MHz"> + <input type="checkbox" id="cb11" name="freqs[]" value="144 MHz"> <label for="cb11">144 MHz</label><br> - <input type="checkbox" id="cb12" name="cb12" value="432 MHz"> + <input type="checkbox" id="cb12" name="freqs[]" value="432 MHz"> <label for="cb12">432 MHz</label><br> - <input type="checkbox" id="cb13" name="cb13" value="1.2 GHz"> + <input type="checkbox" id="cb13" name="freqs[]" value="1.2 GHz"> <label for="cb13">1.2 GHz</label><br> - <input type="checkbox" id="cb14" name="cb14" value="2.3 GHz"> + <input type="checkbox" id="cb14" name="freqs[]" value="2.3 GHz"> <label for="cb14">2.3 GHz</label><br> </fieldset> @@ -121,25 +121,25 @@ if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST['fname']) && isset($_PO <fieldset> <legend>I will use modes:</legend> - <input type="checkbox" id="CW" name="CW" value="CW"> + <input type="checkbox" id="CW" name="modes[]" value="CW"> <label for="CW">CW</label><br> - <input type="checkbox" id="SSB" name="SSB" value="SSB"> + <input type="checkbox" id="SSB" name="modes[]" value="SSB"> <label for="SSB">SSB</label><br> - <input type="checkbox" id="FM" name="FM" value="FM"> + <input type="checkbox" id="FM" name="modes[]" value="FM"> <label for="FM">FM</label><br> - <input type="checkbox" id="RTTY" name="RTTY" value="RTTY"> + <input type="checkbox" id="RTTY" name="modes[]" value="RTTY"> <label for="RTTY">RTTY</label><br> - <input type="checkbox" id="MFSK" name="MFSK" value="MFSK"> + <input type="checkbox" id="MFSK" name="modes[]" value="MFSK"> <label for="MFSK">MFSK (JT65, FT8...)</label><br> - <input type="checkbox" id="IMAGING" name="IMAGING" value="IMAGING"> + <input type="checkbox" id="IMAGING" name="modes[]" value="IMAGING"> <label for="IMAGING">IMAGING (ATV, SSTV...)</label><br> - <input type="checkbox" id="OTHER DIGITAL" name="OTHER DIGITAL" value="OTHER DIGITAL"> + <input type="checkbox" id="OTHER DIGITAL" name="modes[]" value="OTHER DIGITAL"> <label for="OTHER DIGITAL">OTHER DIGITAL</label><br> </fieldset> |