[Solved] Are these php functions correct? [closed]


Please check the below code, what wrong you did are commented in code:-

<?php
error_reporting(E_ALL); // check all error including warning and notice error too
ini_set('display_errors',1); // display errors
    function add($x,$y) {
        $result= $x+$y;
        return $result;
    } // ; not needed

    $number1= $_POST['n_1'];
    $number2= $_POST['n_2'];
    echo $number1." + ".$number2." = ".add($number1,$number2);// using “ is wrong

    for ($i=5;$i<=50;$i+=5) {
        echo $i."</br>";
    } // ; not needed

    $j=10;
    while ($j>0){
        echo $j."</br>"; // using “ is wrong
        $j--;
    }//; not needed
?> <!-- closing  error-->

<!DOCTYPE html>
<html>
    <head>
    </head>
    <body>
        <form action="thisfile.php" method="POST"> <!--// using “ is wrong -->
            <label for="fullname">Full name: </label>
            <input type="text" name="fullname" size="20"></br>
            <label for="data">Data: </label>
            <textarea rows="5" name="data" cols="20"></textarea></br>
            <label for="valid">Valid?: </label>
            <input type="checkbox" name="valid" value="ON"></br>
            <label for="color">Color: </label>
            <input type="radio" value="blue" checked name="color">Blue
            <input type="radio" value="red" checked name="color">Red</br>
            <label for="month">Month: </label>
            <select size="1" name="month">
                <option selected value="january">January</option> 
                <option value="february">February</option>
                <option value="march">March</option>
            </select></br>
            <label for="n_1">Number 1: </label>
            <input type="text" name="n_1" size="20"></br>
            <label for="n_2">Number 2: </label>
            <input type="text" name="n_2" size="20"></br>
            <input type="submit" value="send" name="send">
        </form>
    </body>
</html>

Note:- applying POST data checks (validation) is your responsibility, add them too along with the code. Thanks

1

solved Are these php functions correct? [closed]