Addition of Real and Imaginary numbers in PHP MySQL
Addition of Real and Imaginary numbers in PHP MySQL
In this tutorial, we will cover the following programs;
- Addition of Real and Imaginary numbers
- Addition of Real and Imaginary numbers with form values entered by the user
- Addition of Real and Imaginary numbers with a database
Addition of Real and Imaginary numbers
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | <html> <body> <?php $real1=9; $imag1=2; $real2=4; $imag2=12; $sum1=$real1 + $real2; $sum2=$imag1 + $imag2; echo"<h2>addition of complex number is $sum1+$sum2"; echo "i"; ?> </body> </html> |
Addition of Real and Imaginary numbers with form values entered by the user
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | <html> <body> <h1>Assigment 3</h1> <h2>Addition of Real and Imaginary</h2> <form method="post"> type 1st real number<br><input type="text" name="real1"><br> <br> type 1st umaginary number<br><input type="text" name="imag1"> <br><br> type 2nd real number<br><input type="text" name="real2"><br> <br> type 2nd imaginary number<br><input type="text" name="imag2"> <br><br> <input type="submit" name="submit"> <?php if(isset($_POST['submit'])){ $real1=$_POST['real1']; $imag1=$_POST['imag1']; $real2=$_POST['real2']; $imag2=$_POST['imag2']; $sum1=$real1 + $real2; $sum2=$imag1 + $imag2; echo"<h2>addition of complex number is $sum1+$sum2"; echo "i";} ?> </body> </html> |
Addition of Real and Imaginary numbers with a database
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | <html> <head> <style> div { border: solid black; background-color:#00FF33; align:center; width:900px; height:400px; padding: 20px; } </style> </head> <body> <div> <h1>Assigment 3</h1> <h2>Addition of Real and Imaginary</h2> <form method="post"> Type 1st real number:<input type="text" name="real1"> Type 1st imaginary number:<input type="text" name="imag1"><br><br> Type 2nd real number:<input type="text" name="real2"> Type 2nd imaginary number:<input type="text" name="imag2"><br><br> <input type="submit" name="submit"> <?php $con=mysqli_connect("localhost","root","","add"); if(isset($_POST['submit'])){ $real1=$_POST['real1']; $imag1=$_POST['imag1']; $real2=$_POST['real2']; $imag2=$_POST['imag2']; $sum1=$real1 + $real2; $sum2=$imag1 + $imag2; $sql=mysqli_query($con,"INSERT INTO comp(real,img) VALUES ('$sum1','$sum2')"); echo"<h2>addition of complex number is $sum1+$sum2"; echo "i";} ?> </div> </body> </html> |