Sunday, October 27, 2013

#HariBloggerNasional


Saturday, October 26, 2013

Form Divalidasi Beserta Captcha di PHP

Kembali lagi di PHP

Sekarang saya membahas form seperti di PHP 4

tapi kali ini form saya disertai validasi dan captcha

sebelumnya, di filepdf  ini ada beberapa tipe validasi
ada yang menggunakan kata-kata ataupun gambar

download disini (file-save as)



Lalu sekarang kita bahas tentang captcha

captcha yaitu suatu bentuk uji tantangan-tanggapan (challange-response test) yang digunakan dalam perkomputeran untuk memastikan bahwa jawaban tidak dihasilkan oleh suatu komputer. Proses ini biasanya melibatkan suatu komputer (server) yang meminta seorang pengguna untuk menyelesaikan suatu uji sederhana yang dapat dihasilkan dan dinilai oleh komputer tersebut. Karena komputer lain tidak dapat memecahkan CAPTCHA, pengguna manapun yang dapat memberikan jawaban yang benar akan dianggap sebagai manusia." CAPTCHA.

sebelum itu,  buat gambar untuk background captcha
saya membuatnya di photoshop
misalnya seperti ini
captcha buatanku._.
script captcha.php



<?php
session_start();
$alphaNumeric = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
$random = substr(str_shuffle($alphaNumeric),0,5);
$image = imagecreatefromjpeg("images/captcha.jpg");
$textcolor = imagecolorallocate ($image, 2, 1, 3); //hitam
imagestring ($image, 5, 5, 8, $random, $textcolor);
$_SESSION['image_random_value']=md5($random);
//header("Expires: MOn, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s"). " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header('Content-type: image/jpeg');
imagejpeg($image);
imagedestroy($image);
?>



Buat frm.php
sebenarnya intinya sama seperti php sebelumnya
tapi disini scriptnya lebih banyak dan sedikit ruwet.

<?php
    session_start();
    if(isset($_SESSION['error'])){
 $error = $_SESSION['error'];
    $true = $_SESSION['true'];
 $_POST = $_SESSION['post'];
 unset ($_SESSION['error']);
    unset ($_SESSION['true']);
 unset ($_SESSION['post']);
    }

 if (empty($nama) || empty($gender) || empty($email) || empty($alamat) || empty($tempat) || empty($pwd) || empty($agama) || empty($noHP) || empty($captcha) || empty($hari) ||empty($tahun) ||empty($bulan) ){
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="nah.css" />
<title>Formulir</title>
</head>

<body style="background-image:url(images/bcg.png); background-repeat:repeat;">
<form action="action.php" name="form1" method="post">
<center>

<h2><font color="#FFFFFF"> Masukkan data dirimu di Form berikut :</font></h2>
<table  cellspacing="0" cellpadding="0" bgcolor="#FFFFFF" border="0" width="700" height="420" Style='border-radius:10px;border-color:white;
box-shadow: 0 0 5px 5px black;'>

 <tr>
     <td rowspan="11" width="230" Style=' border-top-left-radius:20px;border-bottom-left-radius:20px '><center><img src="images/img.jpg" width="200" 0height="200" /></center></td>
        <td colspan="3" Style=' border-top-right-radius:20px; '>
         <center><font color="#445B23"><b>INPUTAN BIODATA</b></font></center>
        </td>
       
    </tr>
    <tr>
     <td> Nama Lengkap</td>
        <td width="1"><center>:</center></td>
        <td><input  type='text' name="nama" size="40" placeholder="Nama Lengkap" value="<?php echo isset($_POST['nama']) ? $_POST['nama'] : ''; ?>" />
   <font size="-1" color="red"><?php echo isset($error['nama']) ? $error['nama'] : '';?></font>
        <font ><?php echo isset ($true['nama'])? $true['nama'] : '';?></font>
        </td>
    </tr>
    <tr>
     <td> Jenis Kelamin</td>
        <td><center>:</center></td>
        <td>
        <input type="radio" name="gender" value="<?php echo isset($_POST['gender']) ? $_POST['gender'] : ''; ?>Laki - Laki <?php echo isset($_POST['gender']) ? ' checked' : ''; ?>"/>&nbsp;Laki-Laki
   
            <input type="radio"  name=gender value="<?php echo isset($_POST['gender']) ? $_POST['gender'] : ''; ?> Perempuan <?php echo isset($_POST['gender']) ? ' checked' : ''; ?>" />&nbsp;Perempuan
            <font size="-1" color="red"><?php echo isset($error['gender']) ? $error['gender'] : '';?></font>
     <?php echo isset ($true['gender'])? $true['gender'] : '';?>
     
        </td>
    </tr>
   
    <tr>
     <td>TTL</td>
        <td><center>:</center></td>
        <td>
    <input type='text' placeholder="Tempat" name="tempat" size="4" value="<?php echo isset($_POST['tempat']) ? $_POST['tempat'] : ''; ?>" />
        <font size="-1"  color="red"><?php echo isset($error['tempat']) ? $error['tempat'] : '';?></font>
  <font ><?php echo isset ($true['tempat'])? $true['tempat'] : '';?></font>


<?php
$bulan=array("Januari" ,"Februari", " Maret" ,"April", "Mei", "Juni",
"Juli", "Agustus", "September", "Oktober", "November", "Desember");



echo '<select name="hari" >';
echo "<option value=hari>Hari</option>";
$hari=1;
$haripilih = isset($_POST['hari']) ? $_POST['hari'] : "hari";

while($hari<=31) {
echo "<option value=$hari";
echo  $hari == $haripilih ? " selected" : "";
echo '>'.$hari.'</option>';
$hari++;
}
echo '</select>';

echo '<select name="bulan">';
echo "<option value=bulan>Bulan</option>";
$jumlah=count($bulan);
$bulanpilih = isset($_POST['bulan']) ? $_POST['bulan'] : "bulan";
for($i=0; $i<$jumlah ; $i++){
 echo "<option value=$bulan[$i]";
 echo $bulan[$i] == $bulanpilih ? " selected" : "";
 echo '>'.$bulan[$i].'</option>';
}
echo '</select>';


echo '<select name="tahun">';
echo "<option value=tahun>Tahun</option>";
$tahunpilih = isset($_POST['tahun']) ? $_POST['tahun'] : "tahun";
for($tahun=1995; $tahun<2010; $tahun++){
echo "<option value='$tahun'";
echo $tahun == $tahunpilih? " selected" : "";
 echo '>'.$tahun.'</option>';
}
echo '</option>';

?>
        </td>
    </tr>
    <tr>
    <td>Agama</td>
        <td><center>:</center></td>
        <td><input type='text' placeholder="Agama" name="agama" size="40" value="<?php echo isset($_POST['agama']) ? $_POST['agama'] : ''; ?>" />
        <font size="-1" color="red"><?php echo isset($error['agama']) ? $error['agama'] : '';?></font>
        <font ><?php echo isset ($true['agama'])? $true['agama'] : '';?></font>
        </td></tr>
     <td>E-mail</td>
        <td><center>:</center></td>
        <td><input type='text' name="email" placeholder="E-mail" size="40" value="<?php echo isset($_POST['email']) ? $_POST['email'] : ''; ?>" />
        <font size="-1" color="red"><?php echo isset($error['email']) ? $error['email'] : '';?></font>
        <font ><?php echo isset ($true['email'])? $true['email'] : '';?></font>
        </td>
    </tr>
    <tr>
    <td>Password</td>
        <td><center>:</center></td>
        <td><input type='password' placeholder="Password" name="pwd" size="40" value="<?php echo isset($_POST['pwd']) ? $_POST['pwd'] : ''; ?>" />
        <font size="-1" color="red"><?php echo isset($error['pwd']) ? $error['pwd'] : '';?></font>
        <font ><?php echo isset ($true['pwd'])? $true['pwd'] : '';?></font>
        </td>
     </tr>
     <tr>
     <td>Alamat</td>
        <td><center>:</center></td>
        <td><input type='text' placeholder="Alamat" name="alamat" size="40" value="<?php echo isset($_POST['alamat']) ? $_POST['alamat'] : ''; ?>" />
        <font size="-1" color="red"><?php echo isset($error['alamat']) ? $error['alamat'] : '';?></font>
        <font ><?php echo isset ($true['alamat'])? $true['alamat'] : '';?></font>
        </td>
        </tr>
    <tr>
     <td>No. HP</td>
        <td><center>:</center></td>
        <td><input type='text' placeholder="No.HP" name="HP" size="40" value="<?php echo isset($_POST['HP']) ? $_POST['HP'] : ''; ?>" />
        <font size="-1" color="red"><?php echo isset($error['HP']) ? $error['HP'] : '';?></font>
        <font ><?php echo isset ($true['HP'])? $true['HP'] : '';?></font>
        </td>
    </tr>
     <tr>
     <td>Captcha  <img height="30" style="vertical-align:middle;" src="captcha.php?data=<?php echo date('YmdHis');?> alt="securiy image" /></td>
        <td><center>:</center></td>
        <td>
       
         <input name="pin" placeholder="Captcha" type="text"  value="<?php echo isset($_POST['captcha']) ? $_POST['captcha'] : ''; ?>" />
         
        <font size="-1" color="red"><?php echo isset($error['pin']) ? $error['pin'] : '';?></font>
        <font ><?php echo isset ($true['pin'])? $true['pin'] : '';?></font>
 
        </td>
    </tr>
    <tr>

     <td colspan="3"  Style=' border-bottom-right-radius:20px;'><center>&nbsp;
  <button type="submit" name="submit">&nbsp;Kirim&nbsp;</button>&nbsp;<button type="reset" value="Refresh" ONCLICK="history.go(0)">&nbsp;Reset&nbsp;</button></center>
  </td>      
    </tr>

</table>
</center>
</form>
<?php } ?>
</body>
</html>


 hasilnya




Siapkan gambar untuk tampilan error, sebenarnya ini sesuai selera masing masing

1. untuk yang benar
2. data yang dimasukkan kurang benar

3. inputan salah

usahakan gambar kecil saja, kalau belum kecil tinggal rezise

lalu buat action.php untuk menampilkan yang sudah diinputkan tadi


<link rel="stylesheet" type="text/css" href="nah.css" />
  <title>Hasil</title>

    <body style="background-image:url(images/bcg.png); background-repeat:repeat;">
<?php
session_start();
if($_POST){
$nama=$_POST['nama'];
$gender=isset($_POST['gender'])? $_POST['gender']:"";
$tempat=$_POST['tempat'];
$hari=$_POST['hari'];
$bulan=$_POST['bulan'];
$tahun=$_POST['tahun'];
$agama=$_POST['agama'];
$alamat=$_POST['alamat'];
$email=$_POST['email'];
$pwd=$_POST['pwd'];
$noHP=$_POST['HP'];

$CAPTCHA=$_POST['pin'];
$emailpattern = '/^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/';

$imgTrue ='<img src="images/true.png" style="vertical-align:middle"/><br>';
$imgEmp ='<img src="images/false.png" style="vertical-align:middle"/><br>';
$imgErr ='<img src="images/warning.png" style="vertical-align:middle"/><br>';


$error = array();
    if(empty ($nama)){
        $error['nama'] = $imgEmp.'Nama harus diisi';
    } else if(preg_match('/[^a-zA-Z ]/', $nama))           {
        $error['nama'] = $imgErr.'Nama hanya mengandung huruf saja';
    } else{
        $true['nama'] = $imgTrue;
    }

if(empty ($agama)){
        $error['agamat'] = $imgEmp.'Agama tidak boleh kosong';

    } else{
        $true['agama'] = $imgTrue;
    }

    if(empty ($email)){
        $error['email'] = $imgEmp.'Email tidak boleh kosong';
    } elseif (!preg_match($emailpattern, $email)){
        $error['email'] = $imgErr.'Format Email  (xxxxxxx@xxxxx.xxx)';
    } else{
        $true['email'] = $imgTrue;
    }

 if(empty ($alamat)){
        $error['alamat'] = $imgEmp.'Alamat tidak boleh kosong';

    } else{
        $true['alamat'] = $imgTrue;
    }

 if(empty ($pwd)){
        $error['pwd'] = $imgEmp.'Password tidak boleh kosong';

    } else{
        $true['pwd'] = $imgTrue;
    }

 if (empty($gender)){
  $error['gender'] = $imgEmp.'Jenis kelamin masih kosong!'; 
 } else{
  $true['gender'] = $imgTrue;
 }

 if(empty ($tempat)){
        $error['tempat'] = $imgEmp.'TTL tidak boleh kosong';

    } else{
        $true['tempat'] = $imgTrue;
    }

 if(empty ($noHP)){
        $error['HP'] = $imgEmp.'No HP tidak boleh kosong';

    }  else if(preg_match('/[^0-9 ]/', $noHP))           {
        $error['HP'] = $imgErr.'Nomer HP hanya mengandung angka saja';
 }
 else{
        $true['HP'] = $imgTrue;
    }

 if(empty ($CAPTCHA)){
        $error['pin'] = $imgEmp.'Anda harus mengisi captcha';

    } elseif (md5($_POST['pin']) <> $_SESSION['image_random_value']){
  $error['pin'] = $imgErr.'Anda bukan manusia';
    
    } else {
      $true['pin'] = $imgTrue;
 }

if(empty($error)){


 if($gender=='Laki - Laki'){
  echo'<h2><font color="white"><center>Selamat Datang Saudara, '.$nama.'<br>Berikut Biodatamu</center></font></h2>';
  }
 else{
  echo'<h2><font color="white"><center>Selamat Datang Saudari, '.$nama.'<br>Berikut Biodatamu</center></font></h2>';
  }
print("
<center>
<table  cellspacing='3' cellpadding='0' bgcolor='#FFFFFF' border='0' width='550' height='300' Style='border-radius:20px;border-color:white;box-shadow: 0 0 5px 5px black; '>
 <tr>
     
        <td colspan='4' Style=' border-top-left-radius:20px; border-top-right-radius:20px'>
         <center><strong><font color='#445B23'><div class='Da'>DATA DIRI</div></font></strong></center>
        </td>
          
    </tr>
    <tr>
     <td> Nama Lengkap </td>
        <td width='1'><center>:</center></td>
        <td> $nama</td>
  

    </tr>
    <tr>
     <td> Jenis Kelamin</td>
        <td><center>:</center></td>
        <td> $gender </td>
    </tr>
  
    <tr>
     <td>TTL</td>
        <td><center>:</center></td>
        <td>$tempat, $hari - $bulan - $tahun</td>
    </tr>
<tr>
     <td>Agama</td>
        <td><center>:</center></td>
        <td> $agama</td>
    </tr>
<tr>
     <td>E-mail</td>
        <td><center>:</center></td>
        <td>$email</td>
    </tr>
    <tr>
     <td>Password</td>
        <td><center>:</center></td>
        <td> $pwd</td>
    </tr>
    <tr>
     <td>Alamat</td>
        <td><center>:</center></td>
        <td> $alamat</td>
    </tr>
    <tr>
     <td Style=' border-bottom-left-radius:20px'>No. HP</td>
        <td><center>:</center></td>
        <td>$noHP</td>
    </tr>
   <tr>
   

</table>
</center>
");

 }

else{
 $_SESSION['error']=$error;
    $_SESSION['true'] =$true;
 $_SESSION['post'] =$_POST;
 header("location:frm.php");
}
}

?>



contoh ketika inputan data ada yang salah :



setelah semuanya benar 








sekian postingan kali ini
Terima kasih :)

Menerapkan Server Control di ASP

Di ASP, kita bisa membuat form melalui web
dengan bantuan komponen-komponen di ASP yang ada di toolbox

ini file yang diberikan guru saya, cukup banyak
ada kira-kira 20 halaman

Kerjakan semuanya satu per satu terlebih dahulu agar paham

Download : file save as disini


berikut caranya



add new item-web form(c#)



Ketikkan script untuk InputBiodata.aspx


<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="InputBiodata.aspx.cs" Inherits="Bab2.InputBiodata" %>

<!DOCTYPE html>


<html xmlns="http://www.w3.org/1999/xhtml">

<head id="Head1" runat="server">
    <title>Inputan</title>
    <link rel="stylesheet" type="text/css" href="nah.css" />

    <style>

        .f {
            font-family: Verdana;
        }
        .auto-style1 {
            width: 712px;
        }
        #Reset1 {
            height: 27px;
            width: 64px;
        }
    </style>
   
</head>
<body Style="background-image:url(bg.png);background-repeat:repeat;">
    <form id="form1" runat="server">
        <center>

            <h2>

<span style="color: white; font-family: Adler;">Pendaftaran Anak Moklet</span></h2>
    <table  class="f" cellspacing="0" cellpadding="7" bgcolor="#FFFFFF" border="0" width="450" height="200" Style='border-color:white; border-radius: 20px;
box-shadow: 0 0 2px 2px white;'>
 <tr>
     <td rowspan="9" width="250" Style=' border-top-left-radius:20px;border-bottom-left-radius:20px '><center><img src="img.jpg" width="200" 0height="200" /></center></td>
        <td colspan="3" Style=' border-top-right-radius:20px; '>
         <center><font color="brown" font size="6">INPUTAN BIODATA</font></center>
        </td>
       
    </tr>
    <tr>
     <td> Nama </td>
        <td width="1"><center>:</center></td>
        <td><asp:TextBox ID="nama" type="text" Size="35" runat="server"
            ></asp:TextBox></td>
    </tr>
    <tr>
     <td> Jenis Kelamin</td>
        <td><center>:</center></td>
        <td class="auto-style1">
     
            <asp:radiobutton groupname="Gender" id="rbtLaki" runat="server" text="Laki-Laki"></asp:radiobutton>
            <asp:radiobutton groupname="Gender" id="rbtPerempuan" runat="server" text="Perempuan"></asp:radiobutton>
            </td>
    </tr>
    <tr>
     <td>E-mail</td>
        <td><center>:</center></td>
        <td><asp:TextBox ID="Email" type="text" Size="35" runat="server"
            ></asp:TextBox></td>
    </tr>
      <tr>
     <td>Password</td>
        <td><center>:</center></td>
          <td><asp:TextBox ID="pwd" type="password" Size="35" runat="server"
            ></asp:TextBox></td>
  </tr>
 
    <tr>
     <td>Alamat</td>
        <td><center>:</center></td>
        <td>
            <asp:TextBox ID="alamat" TextMode="MultiLine" runat="server"></asp:TextBox>                              
        </td>
    </tr>
       
    <tr>
     <td>Cita - Cita</td>
        <td><center>:</center></td>
           
           <td class="auto-style1">
   
            <asp:radiobutton groupname="Cita" id="rbtCita1" runat="server" text="Kuliah"></asp:radiobutton>
<br />          
                <asp:radiobutton groupname="Cita" id="rbtCita2" runat="server" text="Kerja"></asp:radiobutton>
           <br />
                <asp:radiobutton groupname="Cita" id="Cita3" runat="server" text="Yang lain">
            </asp:radiobutton>

<asp:button id="btnOther" onclick="btnOther_Click" runat="server" style="background-color: cornsilk; border-radius: 5px;" text="Pilih"></asp:button>

        <asp:panel id="pnlOther" runat="server" visible="false">Isi Sendiri:
        <asp:textbox id="CitaLain" runat="server"></asp:textbox></asp:panel>
    </td>
    </tr>

    <tr>

     <td colspan="3"  style=' border-bottom-right-radius:20px;'><center>
         <asp:button id="prev" onclick="prev_Click" runat="server" style="background-color: antiquewhite; border-radius: 10px;" text="Preview Di Bawah"></asp:button> &nbsp;

           

            <asp:Button ID="btnSubmit" runat="server" style="background-color: cornsilk; border-radius: 10px;" Text="Submit" PostBackUrl="IBiodataHasil.aspx" Height="27px" Width="56px" OnClick="btnSubmit_Click"></asp:Button> &nbsp;
           <input id="Reset1" type="reset" value="Reset" style="background-color: cornsilk; border-radius: 10px;" /> </center>
  </td>      
    </tr>

</table>

<table aria-dropeffect="popup" width="450" border="0" id="Table1" runat="server" style="background-color: white; border-radius: 20px;">
<tr>
    <td bgcolor="#64481C" colspan="3" style="border-top-left-radius: 20px; border-top-right-radius: 20px;"><center>
<b><span style="color: white;"><h2>Preview</h2>
</span></b></center>
</td>
  </tr>
<tr>
    <td width="99">Nama</td>
    <td width="19">:</td>
    <td width="180">
        <asp:label id="lblNama1" runat="server"></asp:label></td>
  </tr>
<tr>
    <td>Jenis Kelamin</td>
    <td>:</td>
    <td>
        <asp:label id="lblGender1" runat="server"></asp:label></td>
  </tr>
<tr>
    <td>Email</td>
    <td>:</td>
    <td><asp:label id="lblEmail1" runat="server"></asp:label></td>
  </tr>
<tr>
    <td>Password</td>
    <td>:</td>
    <td><asp:label id="lblPassword1" runat="server"></asp:label></td>
  </tr>
<tr>
    <td>Alamat</td>
    <td>:</td>
    <td><asp:label id="lblAlamat1" runat="server"></asp:label></td>
  </tr>
<tr>
    <td style="border-bottom-left-radius: 20px;">Cita-Cita</td>
    <td>:</td>
    <td style="border-bottom-right-radius: 20px;"><asp:label id="lblCita1" runat="server"></asp:label></td>
  </tr>
</table>


</center>

    </form>

</body>

</html>


klik kanan di view code



ketikkan script:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Bab2

{
    public partial class InputBiodata : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Table1.Visible = false;
        }
        protected void btnOther_Click(object sender, EventArgs e)
        {
            if (Cita3.Checked)
                pnlOther.Visible = true;
            else
                pnlOther.Visible = false;
        }


        protected void prev_Click(object sender, EventArgs e)

        {
            Table1.Visible = true;

            lblNama1.Text = nama.Text;



            lblEmail1.Text = Email.Text;



            lblPassword1.Text = pwd.Text;



            lblAlamat1.Text = alamat.Text;


            if (rbtLaki.Checked)

            {
                lblGender1.Text = rbtLaki.Text;
            }
            else if (rbtPerempuan.Checked)
            {
                lblGender1.Text = rbtPerempuan.Text;
            }

            if (rbtCita1.Checked)

            {
                lblCita1.Text = rbtCita1.Text;
            }
            else if (rbtCita2.Checked)
            {
                lblCita1.Text = rbtCita2.Text;
            }
            else if (Cita3.Checked)
            {
                lblCita1.Text = CitaLain.Text;
            }

        }


        public String varGdr;

        public string varCita;
        public string varSdr;
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            if (rbtLaki.Checked)
            {
                varGdr = rbtLaki.Text;
                varSdr = "Saudara";
            }
            else if (rbtPerempuan.Checked)
            {
                varGdr = rbtPerempuan.Text;
                varSdr = "Saudari";
            }
            if (rbtCita1.Checked)
            {
                varCita = rbtCita1.Text;
            }
            else if (rbtCita2.Checked)
            {
                varCita = rbtCita2.Text;
            }
            else if (Cita3.Checked)
            {
                varCita = CitaLain.Text;
            }

        }

    }
}


Begini tampilannya



Lalu buat file IBiodataHasil.aspx
sama seperti tadi
Project-New Item-Web

script IBiodataHasil


<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="IBiodataHasil.aspx.cs" Inherits="Bab2.IBiodataHasil" %>
<%@ PreviousPageType VirtualPath="~/InputBiodata.aspx" %>
<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">

<head id="Head1" runat="server">
    <title>Hasil</title>
        <link rel="stylesheet" type="text/css" href="nah.css" />
    <style type="text/css">
        .labelStyle {
            color: red;
        }
    </style>
</head>
<body Style="background-image:url(bg.png);background-repeat:repeat;">
    <form id="form1" runat="server"><center>
       <font face="Adler" color="white">
           <asp:Label ID="Label1" runat="server"></asp:Label></font>

    <center><table  cellspacing='0' cellpadding='6' bgcolor='#FFFFFF' border='0' width='450' height='300' Style='border-radius:10px;border-color:white; box-shadow: 0 0 2px 2px white; '>

 <tr>
     
        <td colspan='3' bgcolor="#64481C"  Style=' border-top-left-radius:10px; border-top-right-radius:10px'>
         <center><strong><font color='white'>DATA DIRI</font></strong></center>
        </td>
          
    </tr>
    <tr>
     <td> Nama Lengkap </td>
        <td width='1'><center>:</center></td>
        <td><asp:Label ID="lblNama" runat="server" Text="Label"></asp:Label></td>
  

    </tr>

    <tr>
     <td> Jenis Kelamin</td>
        <td><center>:</center></td>
        <td><asp:Label ID="lblGender" runat="server" ></asp:Label></td>
    </tr>
  
  
    <tr>
     <td>E-mail</td>
        <td><center>:</center></td>
        <td><asp:Label ID="lblEmail" runat="server" Text="Label"></asp:Label></td>
    </tr>
    <tr>
     <td>Password</td>
        <td><center>:</center></td>
        <td><asp:Label ID="lblPwd" runat="server" Text="Label"></asp:Label></td>
    </tr>
    <tr>
     <td>Alamat</td>
        <td><center>:</center></td>
        <td><asp:Label ID="lblAlamat" runat="server" ></asp:Label></td>
    </tr>
    <tr>
     <td Style=' border-bottom-left-radius:20px'>Cita - Cita</td>
        <td><center>:</center></td>
        <td Style=' border-bottom-Right-radius:20px'><asp:Label ID="lblCita" runat="server" ></asp:Label></td>
    </tr>
   <tr>
       <td colspan="3"> <center>Data dimasukkan pukul <asp:Label ID="lblTime" runat="server" Text="Label" Font-Size="Large"
            CssClass="labelStyle"/></center></td>
   </tr>

</table></center>

    </form>
</body>
</html>


"<%@ PreviousPageType VirtualPath="~/InputBiodata.aspx" %> 
script ini menunjukkan bahwa InputBiodata adalah previous page dari IBiodataHasil.aspx

view code IBiodataHasil :



using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Bab2

{
    public partial class IBiodataHasil : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Page.PreviousPage != null)
            {

                lblTime.Text = DateTime.Now.ToString("T");


                TextBox Nama = (TextBox)PreviousPage.FindControl("Nama");

                lblNama.Text = Nama.Text;

                TextBox Email = (TextBox)PreviousPage.FindControl("Email");

                lblEmail.Text = Email.Text;

                TextBox pwd = (TextBox)PreviousPage.FindControl("pwd");

                lblPwd.Text = pwd.Text;

                TextBox Alamat = (TextBox)PreviousPage.FindControl("Alamat");

                lblAlamat.Text = Alamat.Text;

                Label1.Text = "Selamat Datang " + PreviousPage.varSdr + " " + Nama.Text;


                lblGender.Text = PreviousPage.varGdr;


                lblCita.Text = PreviousPage.varCita;





            }

        }
    }
}


textbox untuk Isi sendiri akan ada jika radiobutton Yang lain dichecked


Tampilan jika di Preview
(satu halaman)




ditampilkan di halaman lain
~
Powered by Blogger.
 

Blog Template by jun

Copyrights © 2011