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
PHP program to convert a decimal number into binary
In this example, programmer stores the values in the variables. However, if you interested to see the program about taking values in the form, please see example 2.
|
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"; ?> |
PHP program to convert a decimal number into binary with form
In this example, we will take the inputs from the user and store them in variables.
|
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"; } ?> |
PHP program to convert a decimal number into binary with database
In this example, we will take the inputs from the user and temporarily store them in variables and then finally stores them permanently in the 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 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

Order PDF of any content from our website with a little minor Fee to donate for hard work. Online MCQs are fully free but PDF books are paid.
For details: contact whatsapp +923028700085
Important notes based PDF Books are available in very little price, starting from 2$;
Order Now: contact whatsapp +923028700085