My students need to enter their class name on my webpage, because that locates them in my excel tables. Some of them enter weird and wonderful things there!
I am not too clear on how to formulate ‘if not’ in php. So far I have:
$classes = array('18BE1', '18BE2', '18BE3');
$class = $_POST['class'];
//First, check if the student entered the class name correctly
if(in_array($class, $classes)) = false {
echo " 错误:班号不对! Class name wrong! <br> ";
echo " Please enter the correct class name. <br>";
echo " Your details could not be sent. <br>";
echo " 反回再次试一试! Try again!";
exit;
}
Will that work? In Python I would just write:
if $class not in $classes: