Checkbox for showBday and showEmail

This commit is contained in:
Marijn Jansen
2017-01-30 22:42:47 +01:00
parent bc7cbb0fb7
commit ce53b6e9e4
2 changed files with 26 additions and 39 deletions

View File

@@ -110,7 +110,8 @@ function updateSettings() {
WHERE WHERE
`userID` = :userID `userID` = :userID
"); ");
$bday = new DateTime(test_input($_POST["year"] . $_POST["month"] . $_POST["day"])); $bday = new DateTime();
$bday->setDate(test_input($_POST["year"]), test_input($_POST["month"]), test_input($_POST["day"]));
checkBday($bday); checkBday($bday);
$stmt->bindValue(":fname", test_input($_POST["fname"])); $stmt->bindValue(":fname", test_input($_POST["fname"]));
@@ -118,8 +119,8 @@ function updateSettings() {
$stmt->bindValue(":location", test_input($_POST["location"])); $stmt->bindValue(":location", test_input($_POST["location"]));
$stmt->bindValue(":bday", $bday->format("Ymd")); $stmt->bindValue(":bday", $bday->format("Ymd"));
$stmt->bindValue(":bio", test_input($_POST["bio"])); $stmt->bindValue(":bio", test_input($_POST["bio"]));
$stmt->bindValue(":showEmail", test_input($_POST["showEmail"])); $stmt->bindValue(":showEmail", (array_key_exists("showEmail", $_POST) ? "1" : "0"));
$stmt->bindValue(":showBday",test_input($_POST["showBday"])); $stmt->bindValue(":showBday", (array_key_exists("showBday", $_POST) ? "1" : "0"));
$stmt->bindValue(":userID", $_SESSION["userID"]); $stmt->bindValue(":userID", $_SESSION["userID"]);
$stmt->execute(); $stmt->execute();

View File

@@ -45,30 +45,30 @@ $settings = getSettings();
<li> <li>
<label for="bday">Geboortedatum</label> <label for="bday">Geboortedatum</label>
<?php $currentbday = new DateTime($settings["birthdate"]);?> <?php $currentbday = new DateTime($settings["birthdate"]);?>
<select name='day'>"; <select name='day' id="bday">
<?php for ($day = 1; $day < 32; $day++): <?php for ($day = 1; $day <= 31; $day++):?>
$day = sprintf("%02d", $day); ?>
<option value='<?=$day?>' <option value='<?=$day?>'
<?= ($day == $currentbday->format("d")) ? "selected" : ""?> <?= ($day == $currentbday->format("d")) ? "selected" : ""?>
><?=$day?></option>"; ><?=$day?></option>";
<?php endfor; ?> <?php endfor; ?>
</select> </select>
<select name='month'> <select name='month' id="bday">
<option value='01' <?=('01' == $currentbday->format("m")) ? "selected" : ""?>>januari</option> <?php
<option value='02' <?=('02' == $currentbday->format("m")) ? "selected" : ""?>>februari</option> $months = array ("januari", "februari", "maart", "april", "mei", "juni", "juli", "augustus",
<option value='03' <?=('03' == $currentbday->format("m")) ? "selected" : ""?>>maart</option> "september", "oktober", "november", "december");
<option value='04' <?=('04' == $currentbday->format("m")) ? "selected" : ""?>>april</option> for ($month = 1; $month <= 12; $month++):
<option value='05' <?=('05' == $currentbday->format("m")) ? "selected" : ""?>>mei</option> ?>
<option value='06' <?=('06' == $currentbday->format("m")) ? "selected" : ""?>>juni</option> <option value='<?=$month?>'
<option value='07' <?=('07' == $currentbday->format("m")) ? "selected" : ""?>>juli</option> <?=($month == $currentbday->format("m")) ? "selected" : ""?>
<option value='08' <?=('08' == $currentbday->format("m")) ? "selected" : ""?>>augustus</option> >
<option value='09' <?=('09' == $currentbday->format("m")) ? "selected" : ""?>>september</option> <?= $months[$month - 1]?>
<option value='10' <?=('10' == $currentbday->format("m")) ? "selected" : ""?>>oktober</option> </option>
<option value='11' <?=('11' == $currentbday->format("m")) ? "selected" : ""?>>november</option> <?php endfor;?>
<option value='12' <?=('12' == $currentbday->format("m")) ? "selected" : ""?>>december</option>
</select> </select>
<select name='year'>";
<select name='year' id="bday">
<?php <?php
$now = (new DateTime)->format("Y"); $now = (new DateTime)->format("Y");
for ($year = $now; $year >= 1900; $year--): ?> for ($year = $now; $year >= 1900; $year--): ?>
@@ -80,33 +80,19 @@ $settings = getSettings();
</li> </li>
<li> <li>
<label for="showBday">Toon leeftijd</label> <label for="showBday">Toon leeftijd</label>
<input type="radio" <input type="checkbox"
name="showBday" name="showBday"
id="showBday" id="showBday"
value="1"
<?= ($settings["showBday"] ? "checked" : "")?> <?= ($settings["showBday"] ? "checked" : "")?>
> Ja >
<input type="radio"
name="showBday"
id="showBday"
value="0"
<?= ($settings["showBday"] ? "" : "checked")?>
> Nee
</li> </li>
<li> <li>
<label for="showEmail">Toon Email</label> <label for="showEmail">Toon Email</label>
<input type="radio" <input type="checkbox"
name="showEmail" name="showEmail"
id="showEmail" id="showEmail"
value="1"
<?= ($settings["showEmail"] ? "checked" : "")?> <?= ($settings["showEmail"] ? "checked" : "")?>
> Ja >
<input type="radio"
name="showEmail"
id="showEmail"
value="0"
<?= ($settings["showEmail"] ? "" : "checked")?>
> Nee
</li> </li>
<li> <li>
<label for="bio">Bio</label> <label for="bio">Bio</label>