HTML:

<select name='pol'> <option value="m">Мужской</option> <option value="f">Женский</option> </select> 

PHP:

 if (isset($_POST['pol'])) { $pol=$_POST['pol']; if ($pol =='') { unset($pol); } } 

How to make it so that if the variable pol is not equal to m or f, it displays an error? (How will it not be equal? ​​Someone can go to “View Code” and edit it)

  • What do you mean by "displaying an error"? - Ep1demic
  • Write in php-code a comparison with m and f, if not equal - output what you need. You already know how to write comparisons, judging by the example, and most likely also output something - I did not understand something, what is the problem - andreymal
  • I mean to output "Error" - Igor Vasiliev

0