login php dan konverter bilangan desimal

langsung aja ya,,,
1.buka netbeansnya <ato yang lain> tentunya.
2.buat new php for web file untuk validatornya.
3.beri nama .
for some info : nama ini juga sangat penting karena digunakan untuk pemanggilan

4. .masukkan kode seperti gambar
php ganteng

php ganteng

php ganteng

php ganteng
kalo males nulis
<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<?php
if(isset($_POST['submit'])){
    $nama=$_REQUEST['nama'];
    if(isset($_POST['gender'])){
        $gender=$_REQUEST['gender'];
       
    }
    else{
        $gender='';
    }
    $cek='';
}
else{
    $nama='';
    $gender='';
    $cek="harus diisi lengkap!!";
}
?>
<!DOCTYPE html>
<center>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>conditional</title>
        <style type="text/css">
            body
            .a{
                font-family:chiller;
                color:royalblue;
            }
            .b{
                text-shadow:9px 5px 9px red;
                font-family:TimesNewRoman;
                color:black;
            }
            form input.highlight{
                background:left;
                border: solid 1px #CCCCCC;
                border-radius:5px;
                padding: 5px;
            }
           
        </style>
       
    </head>
    <body background="kucing21.jpg">
        <h1 class='a'><?php echo $cek ?></h1><br>
      <form action="konversi_biner_dll.php" method="post" name="form1">
        <h3 class='b'> <p>NAMA : <input type="text" name="nama" value="<?php echo $nama ?>"/></p></h3>
        <h3 class='b'> jenis kelamin :  <input type="radio" name="gender" value="L"
                                  <?php ($gender=="p")? print 'checked=""' : print ''; ?>/>
           laki - laki
           <input type="radio" name="gender" value="p"
                  <?php ($gender=="L") ? print 'checked=""': print ''; ?>/>
           perempuan</h3>
        <input type="submit" name="submit" value="click here to enter"/>
    </form>
     <?php  
    
     if(isset($_POST['submit'])) {// apakah data ter-submit?
     /*membuat variable untuk menyimpan data yg dikirim*/
         $nama=$_REQUEST['nama'];
         if(isset($_POST['gender'])) {
             $gender=$_REQUEST['gender'];
         }
    
     else{
         $gender='';
     }
     //cek apakah data yg dikirim tidak kosong
     if($nama=='' || $gender==''){
         echo '<h2>maaf data kurang lengkap</h2>';
        
     }else{
         /*cek jenis kelamin*/
   if($gender=='L'){
       echo '<h2>selamat datang kakang, '.$nama.' !!</h2>';
      
       }else{
           echo '<h2>selamat datang embak, '.$nama.' !!</h2>';
       }
   }
   echo "<a href='".$_SERVER['PHP_SELF']."'>RESET</a>"; 
      }
     
        ?>
    </body></center>
</html>


5.buat baru lagi
kalo yang ini buat konverternya
6.kasih nama <ini juga penting>
7. masukkan kode dibawah ini :
php ganteng
php ganteng


php ganteng

php ganteng

php ganteng

php ganteng

php ganteng

php ganteng

php ganteng

php ganteng

kalo yg males nulis :
<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<?php
if(isset($_POST['submit'])){
    $nama=$_REQUEST['nama'];
    if(isset($_POST['gender'])){
        $gender=$_REQUEST['gender'];
       
    }
    else{
        $gender='';
    }
    $cek='';
}
else{
    $nama='';
    $gender='';
    $cek="harus diisi lengkap!!";
}
?>
<!DOCTYPE html>

<?php
if(isset($_POST['submit1'])){
$decimal=$_REQUEST['decimal'];
    if(isset($_POST['pilih'])){
        $pilih=$_REQUEST['pilih'];
    }
    else{
        $pilih='';
    }
}
else{
    $decimal='';
    $pilih='';
}
?>
<html>
    <center>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Konversi Bilangan</title>
                <style type="text/css">
            body
            a {
                width: 230px;
                -webkit-transition: all 1s ease-in-out;
                -moz-transition: all 1s ease-in-out;
                -o-transition: all 1s ease-in-out;
                font:18px Times;
                font-weight: bold;
                color: #0000CC;
                margin: 20px;
                text-align: center;
                padding: 10px;
                border-radius: 12px;
                -moz-border-radius: 12px;
                -webkit-border-radius: 12px;
                background:#990000;
                text-decoration: none;
                text-shadow: none;
            }
            a:hover{
                background: chartreuse;
            }
            a:active{
                color: #990000;
            }
            .b{
                color:forestgreen;
                font-family:Rockwell;
                font-weight:bold;
            }
            .bayangan{
                text-shadow:4px 0px 7px red;
                font-family:AcidDreamer;
                font-weight:bold;
                color:#E3941D
            }
                .bayangan1{
                text-shadow:4px 0px 7px black;
                box-shadow:0px 10px 30px green;
                font-family:AcidDreamer;
                font-weight:bold;
                color:#CCFF66;
            }
            form input.highlight{
                background:darkturquoise;
                border: solid 1px #CCCCCC;
                border-radius:5px;
                padding: 5px;
            }
           
        </style>
        <?php
         if($gender=='L'){
       echo '<h2>selamat datang kakang, '.$nama.' !!</h2>';
      
       }else{
           echo '<h2>selamat datang embak, '.$nama.' !!</h2>';
       }  ?>
            <h1 class='b''>Silahkan Konversikan Bilangan </h1>
<tr>
    <td align ="center">
       
    <?php
        if(isset ($_POST['submit'])){
            $nama=$_REQUEST['nama'];
            if(isset($_POST['gender'])){
                $gender=$_REQUEST['gender'];
            }
            else{
                $gender='';
            }
        }
        if(isset ($_POST['submit'])){
        if($nama==''|| $gender==''){// tanda || : OR
            echo"<script>
                 alert('Maaf data kurang lengkap ? Isi Nama dan Jenis Kelamin');
                 document.location.href='Validatornama.php';
                 </script>";//menggunakan javascript
        }
        else{
                   }
        }
    ?>
       
    </td>
    </tr>
</table>
<tr>
    <td align ="center">
    <p>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>
"
          method="POST" name="form1">
        <h4>
 Inputkan Angka Desimal : </h4>
<input class='highlight' placeholder="Input Angka" required="required" type="text" name="decimal" size ="25" value="<?php echo $decimal ?>"/>
        <h4>
 Pilih Konversi yang anda ingin kan : <br>
        <input type="radio" name="pilih" value="B"
               <?php ($pilih=="B")? print 'checked=""' : print ''; ?>/>
        Bilangan Biner<br>
        <input type="radio" name="pilih" value="H"
               <?php ($pilih=="H")? print 'checked=""' : print ''; ?>/>
        Bilangan Hexa<br>
        <input type="radio" name="pilih" value="O"
               <?php ($pilih=="O")? print 'checked=""' : print ''; ?>/>
        Bilangan Oktal<br>
        </h4>
<input type="submit" name="submit1" value="Convert ! !"><br>
    </form>

    </head>
    <body background="kucing21.jpg">
        <!-- Proses Konversi -->
        <?php
      
        if(isset($_POST['submit1'])){//isset : penekanan form
        $decimal=$_REQUEST['decimal'];
            if(isset($_POST['pilih'])){
                $pilih=$_REQUEST['pilih'];
            }
            else{
                $pilih='';
            }
        }
        else{
            $decimal='';
            $pilih='';
        }
        if(isset ($_POST['submit1'])){
        if($decimal==''|| $pilih==''){
            echo"<script>alert('Nilai Desimal gan ..')</script>";//menggunakan javascript
        }
        else{
            if($pilih=='B'){
            //Konversi ke Biner
            if (isset($_POST['decimal'])) {
                $decimal = $_POST['decimal'];
                $original = $_POST['decimal'];
                $binary = '';
                if (preg_match('/[^0-9]/',$decimal)) {
                        die ("Inputan salah");
                }
                else {
                    while ($decimal > 0) {
                        if ($decimal%2 == 0) {
                            $binary .= 0;
                            $decimal /= 2;
                        }
                        else {
                            $binary .= 1;
                            $decimal = ($decimal/2)-0.5;
                        }
                    }
                    $result = strrev($binary);
                    echo "<br><h4>
Bilangan decimal : $original ke biner adalah $result.</h4>
";
                    }
                }
                else {

                }
            }
            else{
                    if($pilih=='H'){
                    //Konversi ke Hexa
                        if(isset($_POST['decimal'])){
                        $des=$_POST['decimal'];
                        $original=$_POST['decimal'];
                        $hex='';
                        while ($des>0){
                        $hasil=$des%16;
                            switch($hasil){
                            case 0 : $hex.="0"; break;
                            case 1 : $hex.="1"; break;
                            case 2 : $hex.="2"; break;
                            case 3 : $hex.="3"; break;
                            case 4 : $hex.="4"; break;
                            case 5 : $hex.="5"; break;
                            case 6 : $hex.="6"; break;
                            case 7 : $hex.="7"; break;
                            case 8 : $hex.="8"; break;
                            case 9 : $hex.="9"; break;
                            case 10: $hex.="A"; break;
                            case 11: $hex.="B"; break;
                            case 12: $hex.="C"; break;
                            case 13: $hex.="D"; break;
                            case 14: $hex.="E"; break;
                            case 15: $hex.="F";
                            default:break;
                            }
                                if($des/16==0){
                                $sisa=($des%16);
                                $des=$sisa;
                                }
                                    else{
                                    $sisa=($des/16);
                                    $des=$sisa%16;
                                    }}
                                    $result = strrev($hex);
                                    echo "<br><h4>
Bilangan decimal : $original ke Hexadecimal adalah $result.</h4>
";
                        }
                    }
                    else{
                        //Konversi ke Oktal
                         if(isset($_POST['decimal'])){
                         $des=$_POST['decimal'];
                         $original=$_POST['decimal'];
                         $octal='';
                         while ($des>0){
                         $hasil=$des%8;
                         switch($hasil){
                         case 0 : $octal.="0"; break;
                         case 1 : $octal.="1"; break;
                         case 2 : $octal.="2"; break;
                         case 3 : $octal.="3"; break;
                         case 4 : $octal.="4"; break;
                         case 5 : $octal.="5"; break;
                         case 6 : $octal.="6"; break;
                         case 7 : $octal.="7";
                         default:break;
                         }
                         if($des/8>0){
                            $sisa=($des/8);
                            $des=$sisa%8;
                            }
                            else{
                            $sisa=($des%8);
                            $des=$sisa;
                            }}
                            $result = strrev($octal);
                            echo "<br><h4>
Bilangan decimal : $original ke Oktal adalah $result.</h4>
";
                            }
                            else{

                            }
                    }
            }
        }
        }
        echo "<br><h4>
<a href='Validatornama.php'>RESET</a></h4>
<br><br>";
        ?>
      
  
  
    <!-- End proses Konversi -->
    </td>
    </tr>
</table>
    </body> </center>
</html>

dan ini hasilnya,, teng teng teng




Untuk Download Artikel Klik Gambar

Tidak ada komentar:

Posting Komentar

 
Powered By irul ganteng | Portal Design By irul nuno © 2009 | Resolution: 1024x768px | Best View: Firefox | Top