Thursday, March 24, 2011

Make Login systems with Php

Login system is one of the most important part of your website, the existance of your website depends on this log in system. So you must keep your login sytem with secure login security systems. Let see some coding may be can use to protect your system log in more secure.



Look the standard form login below


Log in

:
:
coding for standard form log in
<form name="frm login" method="post" action="loginsubmit.php">
            <Table>
            <tr>
            <td>email</td>
            <td>: <input type="text" class="field"  name="textemail"/></td>
            </tr>
            <tr>
            <td>Password</td>
            <td>: <input type="password" class="field"  name="textpassword"/></td>
            </tr>
            <tr>
            <td>&nbsp;</td>
            <td>&nbsp;&nbsp;<img src="captcha.php" /></td>
            </tr>
            <tr>
            <td>sekuriti</td>
            <td>: <input class="field" type="text" name="captcha"  maxlength="10" value="" /></td>
            </tr>
            </Table>
                <div align="center">
                 <input type="submit" class="login-submit" value="Log in" />
                </div>
            </form>

after that use php to make the session of user login, let see the code below

loginsubmit.php


<?php
include ("server.inc");
$username = strtolower($_POST['textusername']);
$password = $_POST['textpassword'];

$result = mysql_query("select ID_user,username,password,kategori from user where username = '$username' and password = '$enkrip_pass'");
if(mysql_num_rows($result) != 0) {
    $baris = mysql_fetch_row($result);
    session_start();
    $ID=$baris[0];
    $username=$baris[1];
    $password=$baris[2];
    $kategori=$baris[3];
    $_SESSION['userID']=$ID;
    $_SESSION['username']=$username;
    $_SESSION['password']=$enkrip_password;
    $_SESSION['kategori']=$kategori;
   
    header("location:home.php?view=$ID_konversi");
    }
?>


*server.inc can find in exercise before

No comments:

Post a Comment

web programming