📜 ⬆️ ⬇️

About form element names in HTML

Did you know that the names of form elements in HTML can be written as arrays. For example, using the following form enters information about the user.
 <form action = '/' method = 'post'>
     Name: <input type = 'text' name = 'user [name]'> <br>
     Gender: <select name = 'user [sex]'>
                 <option value = 'woman'> female
                 <option value = 'man'> male
             </ select> <br>
     eMail: <input type = 'text' name = 'user [email]'> <br>
         <input type = 'submit' value = 'Next'>
 </ form>

Now in PHP this data can be obtained as an array like this:
     $ user = $ _POST ['user']; 

or so:
     $ user = $ _REQUEST ['user']; 

')

Source: https://habr.com/ru/post/59524/


All Articles