Results 1 to 6 of 6

Thread: login problem..help

  1. #1
    Join Date
    Sep 2005
    Location
    Perak
    Posts
    13
    Rep Power
    0

    Question login problem..help

    salam...

    saya nk ty mengenai login yg melibatkan level authentication.Ada sape2 bleh bagi cth x.. Dalam login tue jugak saya ada mlibtkan session..pertlgn anda amat2 dihargai

  2. #2
    Join Date
    Jan 2007
    Location
    Petaling Jaya
    Posts
    867
    Rep Power
    172
    errm....really cant get what u mean, again......

  3. #3
    Join Date
    Jul 2006
    Location
    My
    Posts
    967
    Rep Power
    0
    want a login script sample where the login would be using session and also level authentication feature. not really complicated but I'm kind of malas to code the script right now hehehe.
    first of all, do you know how to code?
    try check this login script I post earlier
    PHP Code:
    <?php
    session_start
    ();

      
    // PROCESS MEMBER LOGIN
     
    if($_POST["username"] && $_POST["password"])
     {
       
    //***** CHANGE THIS USERNAME AND PASSWORD TO YOUR PREFERENCE *****
       
    $username="admin";
       
    $password="pass";
        if(
    $_POST["username"]==$username && $_POST["password"]==$password)
        {
    setcookie("user",$username,time()+3600); $user=$username; print "Login success <br/>\n";}
        else
        {print 
    "Wrong Username and password !<br/>\n";}
     }

    // GET COOKIE INFORMATION
    if(isset($_COOKIE["user"])){$user=$_COOKIE["user"];}

    // PROCESS LOGOUT ACTION
    if(!$_POST && $_GET["action"]=='logout')
    {
    setcookie("user","",time()-3600); unset($user);}

    // GET AUTHORITY TO ACCESS MEMBER AREA
    if($user)
    {

    print 
    "
    Welcome 
    $user <br/>\n
    This is the member section information<br/>\n
    Only member can view this<br/>\n
    <a href=\"?action=logout\">Logout</a><br/>
    "
    ;


    }
    else
    {
     
    // DISPLAY MEMBER LOGIN FORM
    print "
    <form action=\"\" method=\"post\">
    Name <input type=\"text\" name=\"username\" size=\"20\"/> <br/>\n
    Pass <input type=\"password\" name=\"password\" size=\"20\"/> <br/>\n
    <input type=\"submit\" value=\" Login \"/>
    </form>"
    ;
    }


    ?>

  4. #4
    Join Date
    Sep 2005
    Location
    Perak
    Posts
    13
    Rep Power
    0
    nie code yg dibuat:

    login.php

    <form name="form1" method="post" action="login_process.php">
    <table width="56%" height="163" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#9999FF">
    <tr>
    <td><div align="left"></div>
    <div align="center" class="style5">
    <div align="left"></div>
    </div>
    <div align="left"></div>
    <table width="83%" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr>
    <td height="29" colspan="2"><div align="center" class="style2"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong>Login</strong></font></div>
    <div align="center"></div></td>
    </tr>
    <tr>
    <td width="40%" height="30"> <div align="right"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">
    Username<span class="style2">: </span></font></div></td>
    <td width="60%"><div align="left"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">
    <input name="username" type="text" id="username">
    </font></div></td>
    </tr>
    <tr>
    <td height="26"><div align="right"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Password:</font></div></td>
    <td height="26"><div align="left"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">
    <input name="password" type="password" id="password">
    </font></div></td>
    </tr>
    <tr>
    <td height="34" colspan="2"><div align="center" class="style2">
    <font size="2" face="Verdana, Arial, Helvetica, sans-serif">
    <input type="submit" name="Submit" value="Login">
    <input type="reset" name="Submit2" value="Cancel">
    </font></div></td>
    </tr>
    </table></td>
    </tr>
    </table>
    </form>

    login_process.php

    <?php
    session_start();
    $host="localhost"; // Host name
    $username="root"; // Mysql username
    $password=""; // Mysql password
    $db_name="forseti_report"; // Database name
    $tbl_name="user"; // Table name

    // Connect to server and select databse.
    mysql_connect("$host", "$username", "$password")or die("cannot connect");
    mysql_select_db("$db_name")or die("cannot select DB");

    // username and password sent from signup form
    $username=$_POST['username'];
    $password=$_POST['password'];

    $sql="SELECT * FROM $tbl_name WHERE username='$username' and password='$password'";
    $result=mysql_query($sql);

    $count=mysql_num_rows($result);


    if($count==1){

    session_register("user_id");
    session_register("username");
    //echo $username;
    session_register("password");
    session_register("position");
    header("location:main.php");
    }
    else {
    echo "Invalid User Id or Password";
    }
    ?>

    ~nk ty mcm mana kita hy nk buat satu shj login form,tp boleh pelbagai user gunakan utk login.

    contoh:if user as programmer header akan pergi ke page main.php

    if user as project manager header akan pergi ke page index.php

  5. #5
    Join Date
    Jul 2006
    Location
    My
    Posts
    967
    Rep Power
    0
    cuma direct setiap golongan user kepada page tertentu

    if ($position=='admin')
    {header("location:admin.php");}
    elseif
    ($position=='moderator')
    {header("location:mod.php");}
    else
    {header("location:login.php");}

  6. #6
    Join Date
    Sep 2005
    Location
    Perak
    Posts
    13
    Rep Power
    0
    thanks..ok try buat.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Problem with login
    By calvynlee in forum FeedBack & Suggestion
    Replies: 5
    Last Post: 23-05-2007, 06:16 AM
  2. login
    By beih107 in forum Website Programming
    Replies: 2
    Last Post: 17-04-2007, 04:05 PM
  3. login
    By annuR in forum Website Programming
    Replies: 2
    Last Post: 18-05-2006, 02:32 PM
  4. Problem login to yahoo mail ac.
    By sportstoto3368 in forum Website Design
    Replies: 1
    Last Post: 22-10-2004, 06:24 AM
  5. Cannot login to Malaysian Top 50
    By alang in forum Mamak Stall
    Replies: 5
    Last Post: 04-02-2004, 04:33 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Search Engine Optimization by vBSEO 3.5.0 RC1 PL1

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112