PHP program to convert a decimal number into binary with form and database
In this tutorial, we will learn about the followings.- PHP program to convert a decimal number into binary
- PHP program to convert a decimal number into binary with form
- PHP program to convert a decimal number into binary with database
1 2 3 4 5 6 |
<?php $number=10; $mor=0; echo"Dacimal Number is = $number<br>"; $mor=decbin($number); echo"Binary Number is = $mor"; ?> |
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 |
<html> <head> <title></title> </head> <body> <div class="nukr"><h2 class="col_insert" >Reverse Number</h2></div> <form action="" method="post" name="insert_form" id="insert_form" class="comment-form"> <table class="tableI1" align="left" border="0" bordercolor="#FFFFFF" > <tr><td ><b><i>Enter Number</b></i></td> <td><input id="number" name="number" type="text" size="30" /> <tr><td></td><td><input type="submit" id="btnsubmit" name="btnsubmit" value="Calculate" size="30"/></td></tr> <tr><td></td><td> </td></tr> </table> </form> </body> </html> <?php if(isset($_POST['btnsubmit'])) { $number ;$mor=0; $number=$_POST['number']; echo"Dacimal Number is = $number<br>"; $mor=decbin($number); echo"Binary Number is = $mor"; } ?> |
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 43 44 |
<html> <head> <title></title> </head> <body> <div class="nukr"><h2 class="col_insert" >Covert a Number from decimal to binary</h2></div> <form method="post"> <table class="tableI1" align="left" border="0" bordercolor="#FFFFFF" > <tr><td ><b><i>Enter Number</b></i></td> <td><input id="number" name="number" type="text" size="30" /> <tr><td></td><td><input type="submit" id="btnsubmit" name="btnsubmit" value="Calculate" size="30"/></td></tr> <tr><td></td><td> </td></tr> </table> </form> </body> </html> <?php //include 'dbconction.php'; ?> <?php $conn= mysqli_connect('localhost','root','','test'); if(isset($_POST['btnsubmit'])) { $number=$_POST['number']; $rs=$number; $mor=0; echo"Dacimal Number is = $rs<br>"; $mor=decbin($number); echo"Binary Number is = $mor"; $sql= "insert into reves(Numbe, Revers) Value ('$rs','$mor')"; if($conn->query($sql)=== TRUE) { echo"<font color=#FF00FF> New Record Inserted<br></font>"; } else { echo"Error:".$sql."<br>".$conn->error; } } ?> |
Database to convert decimal number into binary
