Jaquio
Apr 13th, 2006, 12:56 AM
Alright, I have been trying an trying there are a few threads out there from where I have tried to make one. It seemed to work, but it actually didn't.. :( Anyways, I want to make a simple login/logout script. Using a Functions.php file holding the login an logout functions. While in the other file, has the login page, an the logout. Something kinda like this.
Functions.php
<?php
require("Header.php");
//Logs you into the site.
Function Login($User, $Pass, $MinRank, $mID){
global $MyRow;
$result = @mysql_query("SELECT * FROM Members WHERE Username = '$User'");
$MyRow = mysql_fetch_array($result);
if($MyRow != Null){
extract($MyRow);
}
if($User == $Username && $Pass == $Password and $Username != NULL){
if($Rank >= $MinRank){
return 1;
} else {
echo("Logged in!, Rank isn't high enough.");
}
} else {
if($mID == 0){
echo("<br><center>
<form action=User_CMD.php method=POST>
Username:<input type=username name=Username>
<br>
Password:<input type=password name=Password>
<br>
<input type=submit value='Login'>
</form></center>
");
} else {
echo("Not Logged in!, mID != 0");
}
}
}
//Logs you out of the site.
Function Logout($User){
//Place logout stuff here.
echo("You are now logged out!");
}
?>
An here is the other.
User_CMD.php
<?php
require("Functions.php");
$Action = $_GET["Action"];
if($Action == NULL){
if(Login($Username, $Password, 0, 0) == 1){
//Display Profile, Console, Private News an whatever else here.
echo("<br>
<center>
Logged in!
</center>
<br>
");
}
}
if($Action == "Logout"){
if(Login($User, $Pass, 0, 0) == 1){
Logout($Username);
}
}
require("Footer.php");
?>
How could I possibly add-in cookies or sessions doesn't matter which ones I use peferably sessions though. Just as long as the user can login an out.
Functions.php
<?php
require("Header.php");
//Logs you into the site.
Function Login($User, $Pass, $MinRank, $mID){
global $MyRow;
$result = @mysql_query("SELECT * FROM Members WHERE Username = '$User'");
$MyRow = mysql_fetch_array($result);
if($MyRow != Null){
extract($MyRow);
}
if($User == $Username && $Pass == $Password and $Username != NULL){
if($Rank >= $MinRank){
return 1;
} else {
echo("Logged in!, Rank isn't high enough.");
}
} else {
if($mID == 0){
echo("<br><center>
<form action=User_CMD.php method=POST>
Username:<input type=username name=Username>
<br>
Password:<input type=password name=Password>
<br>
<input type=submit value='Login'>
</form></center>
");
} else {
echo("Not Logged in!, mID != 0");
}
}
}
//Logs you out of the site.
Function Logout($User){
//Place logout stuff here.
echo("You are now logged out!");
}
?>
An here is the other.
User_CMD.php
<?php
require("Functions.php");
$Action = $_GET["Action"];
if($Action == NULL){
if(Login($Username, $Password, 0, 0) == 1){
//Display Profile, Console, Private News an whatever else here.
echo("<br>
<center>
Logged in!
</center>
<br>
");
}
}
if($Action == "Logout"){
if(Login($User, $Pass, 0, 0) == 1){
Logout($Username);
}
}
require("Footer.php");
?>
How could I possibly add-in cookies or sessions doesn't matter which ones I use peferably sessions though. Just as long as the user can login an out.