Monday, June 20, 2016

If Else Meeting 7

As a further lesson of "if" condition, now we learn on "if ... else " contion. In this lesson there are two choices and only one is fired. If the condition is "true" then the first statement is fired and if "false" the second statement is fired.
This is similar to the previous lesson but different. Pay attention and see the difference from the previous.

<html>
<head>
<title>Conditions - cont</title>
</head>
<body>
<h3>Thank you for entering your data</h3><br>
<h4>The marks result is:</h4>
<?php
$usrname = $_POST[usrname];
$mark = $_POST[mark];
if ($mark >= 60){
print("<h3> $usrname is <font color=blue><b>"Passed"</b></font>
</h3>");
}
else {
print("<h3>
$usrname is <font color=red><b>"Not Passed"</b></font>
</h3>");
}
?>
</body>
</html>

save it as seven.php (this might overwrite the previous file unless you renamed it before save this file) and we still use six.php (in the previous lesson) file to call the form so that we can save time bu not recoding the first/origin file.

The login is, if condition is "true" then the statement in the first { } bracket is executed, if "false" the statement in the second { } bracket is executed.