Author: Ayesh Karunaratne (Ayesh)
Committer: GitHub (web-flow)
Pusher: cmb69
Date: 2022-07-04T13:25:36+02:00

Commit: 
https://github.com/php/web-php/commit/746d3d71efb0293927d30160628219a339123499
Raw diff: 
https://github.com/php/web-php/commit/746d3d71efb0293927d30160628219a339123499.diff

HTML A11y improvements in add-note.php, my.php and vote-note.php

Also use strict comparison in pages that are changed.

Closes GH-610.

Changed paths:
  M  manual/add-note.php
  M  manual/vote-note.php
  M  my.php


Diff:

diff --git a/manual/add-note.php b/manual/add-note.php
index 52c3f5111..69cda77d4 100644
--- a/manual/add-note.php
+++ b/manual/add-note.php
@@ -40,7 +40,7 @@
     $note = preg_replace("/\n{2,}/", "\n\n", $note);
 
     // Don't pass through example username
-    if ($user == "u...@example.com") {
+    if ($user === "u...@example.com") {
         $user = "Anonymous";
     }
 
@@ -85,7 +85,7 @@
     }
 
     // No error was found, and the submit action is required
-    if (!$error && strtolower($_POST['action']) != "preview") {
+    if (!$error && strtolower($_POST['action']) !== "preview") {
 
         $redirip = $_SERVER['HTTP_X_FORWARDED_FOR'] ??
                    ($_SERVER['HTTP_VIA'] ?? '');
@@ -366,19 +366,19 @@
    </td>
   </tr>
   <tr>
-   <th class="subr">Your email address (or name):</th>
-   <td><input type="text" name="user" size="60" maxlength="40" value="<?php 
echo clean($_POST['user']); ?>"></td>
+   <th class="subr"><label for="form-user">Your email address (or 
name)</label>:</th>
+   <td><input id="form-user" type="text" name="user" size="60" maxlength="40" 
required value="<?php echo clean($_POST['user']); ?>"></td>
   </tr>
   <tr>
-   <th class="subr">Your notes:</th>
-   <td><textarea name="note" rows="20" cols="60" wrap="virtual"><?php if 
(isset($_POST['note'])) { echo clean($_POST['note']); } ?></textarea>
+   <th class="subr"><label for="form-note">Your notes</label>:</th>
+   <td><textarea id="form-note" name="note" rows="20" cols="60" wrap="virtual" 
required maxlength="4095" minlength="32"><?php if (isset($_POST['note'])) { 
echo clean($_POST['note']); } ?></textarea>
    <br>
   </td>
   </tr>
   <tr>
-   <th class="subr">Answer to this simple question (SPAM challenge):<br>
+   <th class="subr"><label for="form-answer">Answer to this simple question 
(SPAM challenge)</label>:<br>
    <?php $c = gen_challenge(); echo $c[3]; ?>?</th>
-   <td><input type="text" name="answer" size="60" maxlength="10"> (Example: 
nine)</td>
+   <td><input id="form-answer" type="text" name="answer" size="60" 
maxlength="10" required> (Example: nine)</td>
   </tr>
   <tr>
    <th colspan="2">
diff --git a/manual/vote-note.php b/manual/vote-note.php
index c7040cdb9..4a007d56c 100644
--- a/manual/vote-note.php
+++ b/manual/vote-note.php
@@ -60,10 +60,10 @@
         $error = "Incorrect answer! Please try again.";
       }
       else {
-        if ($_REQUEST['vote'] == 'up') {
+        if ($_REQUEST['vote'] === 'up') {
           $N[$_REQUEST['id']]['votes']['up']++;
         }
-        elseif ($_REQUEST['vote'] == 'down') {
+        elseif ($_REQUEST['vote'] === 'down') {
           $N[$_REQUEST['id']]['votes']['down']++;
         }
         $update = $N[$_REQUEST['id']]['votes']['up'] - 
$N[$_REQUEST['id']]['votes']['down'];
@@ -114,8 +114,8 @@
   <div style="background-color: #f5f5ff; border: 1px solid black; padding: 
15px; width: 90%; margin: auto;">
    <form action="" method="post">
     <div>
-    <p>Please answer this simple SPAM challenge: <strong><?php $c = 
gen_challenge(); echo $c[3]; ?></strong>?<br>
-    <input type="text" name="challenge" maxlength="10"> (Example: nine)</p>
+    <p><label for="form-challenge">Please answer this simple SPAM 
challenge</label>: <strong><?php $c = gen_challenge(); echo $c[3]; 
?></strong>?<br>
+    <input id="form-challenge" type="text" name="challenge" maxlength="10" 
required> (Example: nine)</p>
     <p><input type="submit" value="Vote" name="votenote"></p>
     </div>
     <input type="hidden" name="func" value="<?php echo $c[0]; ?>">
@@ -166,8 +166,8 @@
   <div style="background-color: #f5f5ff; border: 1px solid black; padding: 
15px; width: 90%; margin: auto;">
    <form action="" method="post">
     <div>
-    <p>Please answer this simple SPAM challenge: <strong><?php $c = 
gen_challenge(); echo $c[3]; ?></strong>?<br>
-    <input type="text" name="challenge" maxlength="10"> (Example: nine)</p>
+    <p><label for="form-challenge">Please answer this simple SPAM 
challenge</label>: <strong><?php $c = gen_challenge(); echo $c[3]; 
?></strong>?<br>
+    <input id="form-challenge" type="text" name="challenge" maxlength="10" 
required> (Example: nine)</p>
     <p><input type="submit" value="Vote" name="votenote"></p>
     </div>
     <input type="hidden" name="func" value="<?php echo $c[0]; ?>">
diff --git a/my.php b/my.php
index fd0ddc0bf..b8a18193a 100644
--- a/my.php
+++ b/my.php
@@ -46,7 +46,7 @@
 }
 
 // Assemble form from collected data
-$langpref = "<select name=\"my_lang\">\n" .
+$langpref = "<select id=\"form-my_lang\" name=\"my_lang\">\n" .
             implode("", $options) . "</select>\n";
 
 // Save URL shortcut fallback setting
@@ -55,7 +55,7 @@
 }
 
 if (isset($_POST["showug"])) {
-    myphpnet_showug($_POST["showug"] == "enable");
+    myphpnet_showug($_POST["showug"] === "enable");
 }
 
 // Prepare mirror array
@@ -106,7 +106,7 @@
 // Data for the language settings table
 $langinfo = array(
 
-    "Your preferred language" =>
+    "<label for=\"form-my_lang\">Your preferred language</label>" =>
     $langpref,
 
     "Last seen language" =>
@@ -176,18 +176,18 @@
 </p>
 
 <div class="indent">
- Your setting: <input type="radio" name="urlsearch" value="quickref"
+ Your setting: <input id="form-urlsearch-quickref" type="radio" 
name="urlsearch" value="quickref"
 <?php
 $type = myphpnet_urlsearch();
 if ($type === MYPHPNET_URL_NONE || $type === MYPHPNET_URL_FUNC) {
     echo ' checked="checked"';
 }
-echo '> Function list search <input type="radio" name="urlsearch" 
value="manual"';
+echo '> <label for="form-urlsearch-quickref">Function list search</label> 
<input id="form-urlsearch-manual" type="radio" name="urlsearch" value="manual"';
 if ($type === MYPHPNET_URL_MANUAL) {
     echo ' checked="checked"';
 }
 ?>
-> PHP Documentation search
+> <label for="form-urlsearch-manual">PHP Documentation search</label>
 </div>
 
 <br>

-- 
PHP Webmaster List Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to