Go Back   Webmaster Malaysia Forum » Website Design & Development » Website Programming

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 08-03-2007, 09:46 AM
annuR's Avatar
Novice Webmaster
 
Join Date: Sep 2005
Location: Perak
Posts: 13
Rep Power: 0
annuR is on a distinguished road
Send a message via Yahoo to annuR
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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 08-03-2007, 02:31 PM
yipguseng's Avatar
Lost Webmaster
 
Join Date: Jan 2007
Location: Petaling Jaya
Posts: 857
Rep Power: 42
yipguseng will become famous soon enough yipguseng will become famous soon enough
Send a message via MSN to yipguseng
errm....really cant get what u mean, again......
__________________
Boonage - Freedom is Everything
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 08-03-2007, 10:25 PM
robot's Avatar
Senior Webmaster
 
Join Date: Jul 2006
Location: My
Posts: 969
Rep Power: 48
robot will become famous soon enough
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>"
;
}


?>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 12-03-2007, 11:19 AM
annuR's Avatar
Novice Webmaster
 
Join Date: Sep 2005
Location: Perak
Posts: 13
Rep Power: 0
annuR is on a distinguished road
Send a message via Yahoo to annuR
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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 12-03-2007, 11:35 AM
robot's Avatar
Senior Webmaster
 
Join Date: Jul 2006
Location: My
Posts: 969
Rep Power: 48
robot will become famous soon enough
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");}
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 12-03-2007, 12:12 PM
annuR's Avatar
Novice Webmaster
 
Join Date: Sep 2005
Location: Perak
Posts: 13
Rep Power: 0
annuR is on a distinguished road
Send a message via Yahoo to annuR
thanks..ok try buat.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Login to infomalaya.com infomalaya Websites Review and Suggestion 0 19-08-2006 02:25 PM
login annuR Website Programming 2 18-05-2006 02:32 PM
session login sheismaria Website Programming 2 18-05-2006 02:20 PM
Problem login to yahoo mail ac. sportstoto3368 Website Design 1 22-10-2004 06:24 AM
Cannot login to Malaysian Top 50 alang Mamak Stall 5 04-02-2004 04:33 PM



All times are GMT +8. The time now is 05:39 PM. Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.1.0 vBulletin skin by ForumMonkeys.com.


WebmasterMalaysia.com is Proudly Hosted by Exabytes Semi Dedicated Server.

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