0

How to run php code with html form in solo learn compiler

I have created a simple calculator in Php which require user input from HTML form but When i run it in solo learn editor it shows nothing. Can anyone help me.

20th Sep 2017, 11:26 AM
Siddhesh Pednekar
Siddhesh Pednekar - avatar
7 Answers
+ 4
Missing closing php tag ?> before the closing body tag.
20th Sep 2017, 12:19 PM
Calviղ
Calviղ - avatar
+ 3
Show your code please.
20th Sep 2017, 12:04 PM
Calviղ
Calviղ - avatar
+ 3
Code Playground cannot fully support php form submission.
20th Sep 2017, 1:47 PM
Calviղ
Calviղ - avatar
+ 1
And this code is running fine in pc
20th Sep 2017, 12:26 PM
Siddhesh Pednekar
Siddhesh Pednekar - avatar
+ 1
Really thanks for your support.
20th Sep 2017, 1:53 PM
Siddhesh Pednekar
Siddhesh Pednekar - avatar
0
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title></title> </head> <body> <form>    <input type="text" name="num1"placeholder="Number 1"></br>    <input type="text" name="num2"placeholder="Number 2"></br> <select name="operator">   <option>None</option>    <option>Add</option>     <option>Subtract</option>      <option>Multiply</option>       <option>Divide</option>      </select></br>    <button type="submit" name="submit">    Calculate    </button> </form></br></br> <p>Here is your Answere</p></br> <?php     if(isset($_GET['submit'])){         $result1 = $_GET['num1'];         $result2 = $_GET['num2'];         $operator = $_GET['operator'];                  switch ($operator){             case 'None':             echo "Select Something";             break;                                        case "Add":             echo $result1 + $result2;             break;                           case "Subtract" :             echo $result1 - $result2;             break;                           case "Multiply" :             echo $result1 * $result2;             break;                           case "Divide":             echo $result1 / $result2;        }                        }          </body> </html>      
20th Sep 2017, 12:09 PM
Siddhesh Pednekar
Siddhesh Pednekar - avatar
0
Thanks but it still not working showing error 'unexpected if' <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title></title> </head> <body> <form>    <input type="text" name="num1"placeholder="Number 1"></br>    <input type="text" name="num2"placeholder="Number 2"></br> <select name="operator">   <option>None</option>    <option>Add</option>     <option>Subtract</option>      <option>Multiply</option>       <option>Divide</option>      </select></br>    <button type="submit" name="submit">    Calculate    </button> </form></br></br> <p>Here is your Answere</p></br> <?php     if(isset($_GET['submit'])){         $result1 = $_GET['num1'];         $result2 = $_GET['num2'];         $operator = $_GET['operator'];                  switch ($operator){             case 'None':             echo "Select Something";             break;                                        case "Add":             echo $result1 + $result2;             break;                           case "Subtract" :             echo $result1 - $result2;             break;                           case "Multiply" :             echo $result1 * $result2;             break;                           case "Divide":             echo $result1 / $result2;        }                        }    ?>       </body> </html>      
20th Sep 2017, 12:24 PM
Siddhesh Pednekar
Siddhesh Pednekar - avatar