PEMROSESAN FORM
Contoh Aplikasi:
lihat Gambar berikut:
Ada pun kode html gambar diatas adalah:
<html>
<head>
<title>Login Form sederhana</title>
<script type="text/javascript">
function error1()
{
alert('Password yang anda masukkan salah. Cobalah kembali!');
}
function check()
{
if(formLogin.password.value == "" || formLogin.username.value=="")
{
error1();
}
}
</script>
<style type="text/css">
#textbox1 {
position:center;
width:500px;
height:100px;
z-index:2;
left: 140px;
top: 257px;
}
#textbox2 {
position:center;
width:500px;
height:80px;
z-index:2;
top: 150px;
left: 100px;
}
#textbox3 {
position:absolute;
width:80px;
height:25px;
z-index:2;
left: 234px;
top: 290px;
}
#header{
width:358px;
height:79px;
background-image: url(a.JPG);
}
#background{
width:358px;
height:250px;
background-image: url(pink.JPG);
}
</style>
</head>
<body onLoad="document.formLogin.username.focus();">
<form name="formLogin" method="post" action="code.php">
<div id="header">
</div>
<div id="background">
<div id="textbox1">
<div align="left"><strong><br>
<span >User Name :</span></strong>
<br>
<input type="text" name="username" size="35" value="" style="background-color:#CCFFCC" autocomplete="off">
<br>
<br>
<strong>Password : </strong>
<br>
<input type="password" name="password" size="35" style="background-color:#CCFFCC" autocomplete="off">
<br>
<br>
</div>
</div>
<br>
<div id="textbox3">
<input type="submit" name="submit" value=" L O G I N " onClick="check()">
</div>
</div>
</form>
</body>
</html>
Sesuaikan judul gambar dan format html supaya tidak terjadi error!!
Untuk masuk username dan pasword gunakan kode php berikut:
<!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>
<title>Form Administrator</title>
</head>
<body>
<?php
if(($_POST['username']=='yandria') AND ($_POST['password']=='107533407712')) {
echo 'BERHASIL ^_^'.$_POST['username'];
}
else {
echo "<br><br><br><body text='red'><strong>Sorry, We can't sign in you to this page!!!<br><br><a href='coba.html'><h4>Back to Login</h4></a></strong></body>";
}
?>
</body>
</html>
jika berhasil masuk akan terlihat seperti gambar berikut:
SELAMAT MENCOBA
0 komentar:
Posting Komentar