PlaGuE
Sep 7th, 2005, 03:29 AM
okay i have a login script... now the url link would be index.php?console...
but i wana do it that way....lol
anyways heres the code... that i think im having the trouble with. WHich is located in consolefunctions.php
function check_login($user, $pass, $nRank) {
global $userinfo;
$result = @mysql_query("SELECT * FROM members WHERE username = \"$user\"");
$userinfo = mysql_fetch_array($result);
if($userinfo != NULL)
extract($userinfo);
// If the username matches the result in the mysql query and the password is correct
// return the rank of the user.
if($user == $username && $pass == $password and $username != NULL) {
if($disabled != 1) {
if($rank >= $nRank) {
return 1;
}
else {
echo("
<table width=100% align=center height=4% border=0 cellpadding=3 cellspacing=1 bgcolor=#000000>
<tr>
<td height=25 bgcolor=#333333><div align=center>
$fontString
You are not high enough rank. <center><br><font size=2 face=verdana><b><a href=index.php?console.php>Click Here to return to console</font></b></center>
</div></td>
</tr>
</table> ");
}
}
if($disabled == 1) {
$result = @mysql_query("SELECT * FROM members WHERE username = \"$user\"");
$row = mysql_fetch_array($result);
extract($row);
echo("
<table width=100% align=center height=4% border=0 cellpadding=3 cellspacing=1 bgcolor=#000000>
<tr>
<td height=25 bgcolor=#333333><div align=center>
$fontString
You have been disabled.<br><br>
<font color=#1C86EE size=1 face=verdana>$disabled</font>
</div></td>
</tr>
</table> ");
}
}
else {
if(!$user) {
echo("
<table width=100% align=center height=4% border=0 cellpadding=3 cellspacing=1>
<tr>
<td height=25><div align=center>
<b><font color=FF6600>Please Login.</font></b><br><br>
<p>
<p>
<form action=index.php?console method=post>
<FONT color=#FFFFFF size=2>
<b>Username:<b> <INPUT style=\"border:1px solid #76A5D5; WIDTH: 115px; HEIGHT: 20px; BACKGROUND-COLOR: #ffffff\" type=username name=username size=\"20\"><br>
<b>Password:</b> <INPUT style=\"border:1px solid #76A5D5; WIDTH: 115px; HEIGHT: 20px; BACKGROUND-COLOR: #ffffff\" type=password name=password size=\"20\"><br><br>
<input type='submit' value='submit' name='login'>
</div></td>
</tr>
</table>");
}
else {
echo("
<table width=100% align=center height=4% border=0 cellpadding=3 cellspacing=1>
<tr>
<td height=25><div align=center>
<b><font color=FF6600>Invalid Username or Password</font></b><br><br>
<font color=FF6600>Error:</font> Invalid information was given<br>
Please check the email sent to you for your correct Information.
<p>
<p>
<form action=index.php?console method=post>
<FONT color=#FFFFFF size=2>
<b>Username:<b> <INPUT style=\"border:1px solid #76A5D5; WIDTH: 115px; HEIGHT: 20px; BACKGROUND-COLOR: #ffffff\" type=username name=username size=\"20\"><br>
<b>Password:</b> <INPUT style=\"border:1px solid #76A5D5; WIDTH: 115px; HEIGHT: 20px; BACKGROUND-COLOR: #ffffff\" type=password name=password size=\"20\"><br><br>
<input type='submit' value='submit' name='login'>
</div></td>
</tr>
</table>");
}
}
}
this is the function that uses it.
function consolepages($page) {
switch($page){
default:
if(check_login($_COOKIE['cusername'], $_COOKIE['cpassword'], 0)==1) {
profile($_COOKIE['cusername'], $_SERVER['REMOTE_ADDR']);
displayconsole($_COOKIE['cusername']);
}
break;
case "change_profile":
echo"Change Profile";
break;
now when they hit login... the code for the cookies are activated in the index.php at the top of page.
if(isset($_POST['login'])){
$usern = $_POST['username'];
$passw = $_POST['password'];
setcookie("cpassword", "$passw",time() + 3600);
setcookie("cusername", "$usern",time() + 3600);
}
now when i click login. it asked me to input the stuff again... which is wierd... so plz help.
but i wana do it that way....lol
anyways heres the code... that i think im having the trouble with. WHich is located in consolefunctions.php
function check_login($user, $pass, $nRank) {
global $userinfo;
$result = @mysql_query("SELECT * FROM members WHERE username = \"$user\"");
$userinfo = mysql_fetch_array($result);
if($userinfo != NULL)
extract($userinfo);
// If the username matches the result in the mysql query and the password is correct
// return the rank of the user.
if($user == $username && $pass == $password and $username != NULL) {
if($disabled != 1) {
if($rank >= $nRank) {
return 1;
}
else {
echo("
<table width=100% align=center height=4% border=0 cellpadding=3 cellspacing=1 bgcolor=#000000>
<tr>
<td height=25 bgcolor=#333333><div align=center>
$fontString
You are not high enough rank. <center><br><font size=2 face=verdana><b><a href=index.php?console.php>Click Here to return to console</font></b></center>
</div></td>
</tr>
</table> ");
}
}
if($disabled == 1) {
$result = @mysql_query("SELECT * FROM members WHERE username = \"$user\"");
$row = mysql_fetch_array($result);
extract($row);
echo("
<table width=100% align=center height=4% border=0 cellpadding=3 cellspacing=1 bgcolor=#000000>
<tr>
<td height=25 bgcolor=#333333><div align=center>
$fontString
You have been disabled.<br><br>
<font color=#1C86EE size=1 face=verdana>$disabled</font>
</div></td>
</tr>
</table> ");
}
}
else {
if(!$user) {
echo("
<table width=100% align=center height=4% border=0 cellpadding=3 cellspacing=1>
<tr>
<td height=25><div align=center>
<b><font color=FF6600>Please Login.</font></b><br><br>
<p>
<p>
<form action=index.php?console method=post>
<FONT color=#FFFFFF size=2>
<b>Username:<b> <INPUT style=\"border:1px solid #76A5D5; WIDTH: 115px; HEIGHT: 20px; BACKGROUND-COLOR: #ffffff\" type=username name=username size=\"20\"><br>
<b>Password:</b> <INPUT style=\"border:1px solid #76A5D5; WIDTH: 115px; HEIGHT: 20px; BACKGROUND-COLOR: #ffffff\" type=password name=password size=\"20\"><br><br>
<input type='submit' value='submit' name='login'>
</div></td>
</tr>
</table>");
}
else {
echo("
<table width=100% align=center height=4% border=0 cellpadding=3 cellspacing=1>
<tr>
<td height=25><div align=center>
<b><font color=FF6600>Invalid Username or Password</font></b><br><br>
<font color=FF6600>Error:</font> Invalid information was given<br>
Please check the email sent to you for your correct Information.
<p>
<p>
<form action=index.php?console method=post>
<FONT color=#FFFFFF size=2>
<b>Username:<b> <INPUT style=\"border:1px solid #76A5D5; WIDTH: 115px; HEIGHT: 20px; BACKGROUND-COLOR: #ffffff\" type=username name=username size=\"20\"><br>
<b>Password:</b> <INPUT style=\"border:1px solid #76A5D5; WIDTH: 115px; HEIGHT: 20px; BACKGROUND-COLOR: #ffffff\" type=password name=password size=\"20\"><br><br>
<input type='submit' value='submit' name='login'>
</div></td>
</tr>
</table>");
}
}
}
this is the function that uses it.
function consolepages($page) {
switch($page){
default:
if(check_login($_COOKIE['cusername'], $_COOKIE['cpassword'], 0)==1) {
profile($_COOKIE['cusername'], $_SERVER['REMOTE_ADDR']);
displayconsole($_COOKIE['cusername']);
}
break;
case "change_profile":
echo"Change Profile";
break;
now when they hit login... the code for the cookies are activated in the index.php at the top of page.
if(isset($_POST['login'])){
$usern = $_POST['username'];
$passw = $_POST['password'];
setcookie("cpassword", "$passw",time() + 3600);
setcookie("cusername", "$usern",time() + 3600);
}
now when i click login. it asked me to input the stuff again... which is wierd... so plz help.