Advertisement
| 10.15.2008 at 11:11AM PDT, ID: 23817714 |
|
[x]
Attachment Details
|
||
|
[x]
The Solution Rating System
|
||
With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.
Your Input Matters If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support. Thank you! |
||
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: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: |
<?php session_start();?>
<?php
// location of this script
$thisfile = "login.php";
// relative path location of the authentication script
$auth = "validate.php";
// if the cookie has been set, if not, go to login screen
if (!isset($_SESSION['level'])) {
echo "<meta http-equiv=\"refresh\" content=\"0;URL=$auth?url=$thisfile\">";
} else {
$level = "$_SESSION['level']";
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Login</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?php
//level for views.
if ($level < 1) {
?>
<h1>Welcome Administrator<h1>
<h5><a href="<?php echo "$auth?url=$thisfile&cmd=logout"; ?>">LOGOUT</a></h5>
<?php
} else {
?>
<h1>SECURITY ALERT</h1>
<p>You do not have sufficient level to view this information.</p>
<meta http-equiv="refresh" content="2;URL=<? echo "$auth?url=$thisfile"; ?>>
<?php
}
}
?>
</body>
</html>
validate.php
<?php session_start();
$_SESSION['level'] = 'level'; ?>
<?php
define('DBSERVER', 'localhost');
define('DATABASE', '********');
define('USER', '********');
define('PASSWRD', '********');
define('TABLE', 'users');
$thisfile = basename($SCRIPT_NAME);
$url = $_REQUEST['url'];
$cmd = $_REQUEST['cmd'];
$goto = $thisfile."?url=".$url;
if ($cmd == "logout") {
//let's delete the cookie
unset($_SESSION['level'];
$message = "<p>You have been logged out.</p>";
}
if ($cmd == "verify") {
$slogin = $_POST['username'];
$spassword = $_POST['password'];
//find the login
$sql="SELECT password, level FROM " . TABLE . " WHERE login='$slogin'";
$connection = mysql_connect(DBSERVER,USER,PASSWRD);
$selectdb = mysql_select_db(DATABASE);
$result = mysql_query($sql);
if(mysql_num_rows($result) == 0) {
//login was not found
$message = "<p>Username was not found. Try again? </p>";
} else {
//see what that password is
$row = mysql_fetch_array($result, MYSQL_ASSOC) ;
$password = $row['password'];
$level = $row['level'];
if($password == $spassword) {
//that's a match
$message = "<p>Your level level is $level.</p>";
//set session
echo $_SESSION['level'];
//redirect
$goto = $url;
} else {
//login okay, password did not match
$message = "<p>Password did not match username. Try again? </p>";
}
}
mysql_close($connection);
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>User Validation</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?php
if (($cmd == "verify") or ($cmd == "logout")) {
echo "$message";
?>
<meta http-equiv="refresh" content="2;URL=<?php echo "$goto";?>">
<?php } else { ?>
<h3 align="center">Please enter database username and password:</h3>
<form name="form1" method="post" action="<?php echo "$thisfile";?>">
<div align="center">
<table border="0">
<tr>
<td><strong>Username</strong>:</td>
<td><input name="username" type="text" size="20" maxlength="20"></td>
</tr>
<tr>
<td><strong>Password</strong>:</td>
<td><input name="password" type="password" id="password" size="20" maxlength="20">
</td>
</tr>
<tr>
<td colspan="2"><input type="submit" name="Submit" value="Submit"> <input name="Reset" type="reset" id="Reset" value="Reset"></td>
</tr>
</table>
<input name="cmd" type="hidden" id="cmd" value="verify">
<input name="url" type="hidden" id="url" value="<?php echo "$url" ?>">
</div>
</form>
<?php } ?>
</body>
</html>
|
Advertisement