Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Use a form. </p> <pre><code>&lt;form method="get" action="yourscript.php"&gt; &lt;input type="radio" id="private" name="privacy" value="0"&gt; &lt;label for="private"&gt;Private&lt;/label&gt; &lt;input type="radio" id="public" name="privacy" value="1"&gt; &lt;label for="public"&gt;Public&lt;/label&gt; &lt;input type="submit" value="Save"&gt; &lt;/form&gt; </code></pre> <p>Change your buttons to <code>input</code> elements, which, together with the form, provide a HTML native way to send data to a script without the need for Javascript (although you can use Javascript to enhance the usability later on).</p> <p>Using the <code>label</code> tag, you can assign a text to a radiobutton. This allows this text to be clicked as well, and it also provides better support for screen readers, because they can actually see which text belongs to the radiobutton.</p> <p>An <code>id</code> needs to be unique, so I changed it to <code>private</code> and <code>public</code>. The ids are also used to link the label to. </p> <p>The <code>name</code> determines by which name the value is sent to your script.</p> <p>In PHP, you can use the superglobal <code>$_GET</code>. <code>$_GET['privacy']</code> will contain <code>'0'</code> or <code>'1'</code> depending on the choice made. If the method of the form was <code>post</code>, you could use the superglobal <code>$_POST</code> instead, or you can use <code>$_REQUEST</code>, which contains values from either, so in that case your script doesn't care whether the values were send in the url (get) or in the chunk of invisible post data that is sent along with the request.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload