php if statement html option value

后端 未结 4 914
粉色の甜心
粉色の甜心 2021-02-06 14:49

Suppose you have the following html select statement






in your PHP, you will do:

$_POST['selectedValue'];

if I were you, I would prefer a switch-case incase, there are more than 2 conditions.

Example:

switch($_POST['selectedValue']){
case 'Newest':
    // do Something for Newest
break;
case 'Best Sellers':
    // do Something for Best seller
break;
case 'Alphabetical':
    // do Something for Alphabetical
break;
default:
    // Something went wrong or form has been tampered.
}

提交回复
热议问题