Berikut ini saya akan share sedikit pengetahuan saya tentang bagaimana membuat Menu form login dengan gabungan script PHP dan juga HTML.
Langsung aja berikut Codingnya:
a. Script Htmlnya simpan dengan nama “index.html”
<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.0 Transitional//EN”>
<html>
<head>
<title>FORM LOGIN</title>
</head>
<style type=”text/css”> #body { position:absolute; width:350px; height:240px; z-index:1; left: 350px; top: 100px; background-color: #FFFFFF; border: 2px solid Black; } #bawah{ position:absolute; width:80px; height:30px; z-index:2; left: 250px; top: 130px; } #header{ width:350px; height:60px; top:10px; background-color:#cc33cc; } #tengah{ top:20px; } .style2{ font-size: 17px; font-weight: bold; } .style1{ position:absolute; font-size:20px; top:20px; left:140px; } </style> <script type=”text/javascript”> function error() { alert(‘Masukkan User Name dan Password’); } function check() { if(form1.pass.value == “” || form1.user.value==””) { error(); } } </script> <body onLoad=”document.form1.user.focus();” style=”background-color:#cc99ff”>
<form name=”form1″ method=”post” action=”login.php”> <div id=”body”> <div id=”header”> <div><strong> L O G I N </strong></div> </div> <div id=”tengah” > <div align=”left”> <table width=”350″ border=”0″> <tr> <td width=”121″ style=”text-align:left”><strong>username<strong></td> <td width=”196″> <input name=”user” type=”text” size=”30″ value=”” style=”background-color:#cccccc” autocomplete=”off”></td> </tr> <tr> <td style=”text-align:”><strong>password</strong></td> <td> <input type=”password” name=”pass” size=”30″ style=”background-color:#cccccc” autocomplete=”off”></td> </tr> </table> </div> </div> <div id=”bawah”> <input type=”submit” name=”submit” value=” L O G I N ” onClick=”check()”> </div> </div>
</form>
</body>
</html>
b. Script PHPnya simpan dengan nama “login.php”
<!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>Admin status</title> </head>
<body> <?php if(($_POST[‘user’]==’handexcel’) AND ($_POST[‘pass’]==’20091989′)) { echo “<strong>W E L C O M E :</strong> “.$_POST[‘user’]; } else { echo “<br>
<body text=’red’><strong>maaf anda melakukan kesalahan pengisian username atau password<br></strong>
</body>”; echo “<a href=”index.html”><strong>klik disini</a> untuk login kembali</strong>”; } ?>
</body>
</html>
Bisa langsung dipraktekkan …..
Leave a reply to Virgilio Cancel reply