Click to See Complete Forum and Search --> : Problems With Login
LiL|aaron
01-10-2007, 12:44 AM
Hi,
I seem to be having problems with my login script or the sessions, because i can login no problem but when i try accessing a page, it goes back to the login screen.
Heres my code:
<?php
session_start();
?>
<style type="text/css">
.square{background-image:url(images/square.gif); background-position:left; background-repeat:no-repeat; padding-left:7px; line-height:18px; color:#eaf4fe; text-decoration:none}
.square:hover{color:#c8ef08; text-decoration:underline}
</style>
<body bgcolor="#000000">
<title>Admin</title>
<?php
include 'vars.php';
$action = $_POST['action'];
if (!isset($action)) {
?>
<form id="login" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<font color="#FFFFFF" face="Tahoma" size="-1" style="padding-top: 4px;"><b>Admin Login</b> </font><BR><BR>
<input type="hidden" name="action" value="1">
<table border="0" cellpadding="2" cellspacing="2">
<tr>
<td align="right" valign="top" style="padding-top: 4px;"><font color="#FFFFFF" face="Tahoma" size="-1"><b>Username:</b> </font></td>
<td valign="top">
<input type="Text" name="username" id="username" size="17">
</td>
</tr>
<tr>
<td align="right" valign="top" style="padding-top: 4px;"><font color="#FFFFFF" face="Tahoma" size="-1"><b>Password:</b> </font></td>
<td valign="top">
<input type="password" name="pass" id="pass" size="17" title="Password is case-sensitive!">
</td>
</tr>
<tr>
<td align="right" valign="top" style="padding-top: 4px;"><font color="#FFFFFF" face="Tahoma" size="-1"><b>Language:</b> </font></td>
<td valign="top">
<select name="lang"><option value="eng" selected>English<option value="sp">Spanish<option value="fr">French<option value="de">German</select>
</td>
</table>
<input type="submit" name="submit" value="Submit"><br><br>
</form>
<?
} elseif (($action == 1) || ($_SESSION['auth'] = 1)) {
$auser = $_POST['username'];
$apass = $_POST['pass'];
$language = $_POST['lang'];
if ($auser == $login_user && $apass == $login_pass) {
$_SESSION['auth'] = 1;
$_SESSION['user'] = $auser;
include ('/home/orion/public_html/sIte/language/lang_'.$language.'.php');
?>
<table align="center" width="100%" border="0">
<tr>
<td align="center"><font face="Tahoma" color="#FFFFFF" size="-2"><strong><? echo "".$lang['Welcome']." ".$_SESSION['user']."";?>, <? echo "".$lang['Admin'].""; ?></strong></font><br></td>
</tr>
</table>
<table width="100%" align="center" border="0">
<tr>
<td width="15%" valign="top">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><font face="Tahoma" size="-1" color="#c8ef08"><strong><? echo "".$lang['Navigation'].""; ?></strong></font></td>
</tr>
</table>
<a class="square" href="index.php?id=Home"><font face="Tahoma" size="-1"><? echo "".$lang['EditHome'].""; ?></font></a><br>
<a class="square" href="index.php?id=Downloads"><font face="Tahoma" size="-1"><? echo "".$lang['EditDownloads'].""; ?></font></a><br>
<a class="square" href="index.php?id=Information"><font face="Tahoma" size="-1"><? echo "".$lang['EditInfo'].""; ?></font></a><br>
<a class="square" href="index.php?id=DevTeam"><font face="Tahoma" size="-1"><? echo "".$lang['EditTeam'].""; ?></font></a><br>
<a class="square" href="index.php?id=Recruitment"><font face="Tahoma" size="-1"><? echo "".$lang['EditRecruit'].""; ?></font></a><br>
<a class="square" href="index.php?id=Media"><font face="Tahoma" size="-1"><? echo "".$lang['EditMedia'].""; ?></font></a><br>
<a class="square" href="index.php?id=Affiliates"><font face="Tahoma" size="-1"><? echo "".$lang['EditAffil'].""; ?></font></a><br>
<a class="square" href="index.php?id=Poll"><font face="Tahoma" size="-1"><? echo "".$lang['EditPoll'].""; ?></font></a><br>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><font face="Tahoma" size="-1" color="#c8ef08"><strong><? echo "".$lang['Logout'].""; ?></strong></font></td>
</tr>
</table>
<a class="square" href="index.php?id=Logout"><font face="Tahoma" size="-1"><? echo "".$lang['Logout'].""; ?></font></a></td>
</td>
<td width="70%" valign="top">
<?php
switch($_GET['id']){
case "Home":
include "content/Homepage.php";
break;
case "Downloads":
include "content/Downloads.php";
break;
case "Information":
include "content/Information.php";
break;
case "DevTeam":
include "content/DevTeam.php";
break;
case "Recruitment":
include "content/Recruitment.php";
break;
case "Media":
include "content/Media.php";
break;
case "Affiliates":
include "content/Affiliates.php";
break;
case "Poll":
include "content/Poll.php";
break;
case "Logout":
session_destroy();
echo "<font face='Tahoma' color='#FFFFFF' size='-1'>".$lang['Loggedout']."</font>";
break;
default:
include "blank.php";
}
?>
</td>
</tr>
</table>
</body>
<?
} else {
echo '<font face="Tahoma" size="-1">Login Failed</font>';
}
}
?>
Thanks for any help.
NightShift58
01-10-2007, 01:31 AM
In your script, you have "session_start()" 3 times. It should only be in there once, at the top of the script.case "Logout":
session_start();
session_destroy();
echo "<font face='Tahoma' color='#FFFFFF' size='-1'>".$lang['Loggedout']."</font>";
break;
default:
session_start();
include "blank.php";These two session_start() need to be removed, as it is already present at the top of the script.
In addition, unless something is taking place in the included file "vars.php", the variables $login_user and $login_pass do not seem to be declared anywhere and may not have any values assigned at this point:if ($auser == $login_user && $apass == $login_pass) {
LiL|aaron
01-10-2007, 01:38 AM
I have removed the 2 session_start and it made no difference.
$login_user and $login_pass are declared in the vars.php file.
NightShift58
01-10-2007, 01:43 AM
Except for the two session_start() I don't see anything in the script. If you hide the sensitive stuff, could we have a look at vars.php. It's the only other place where something could go wrong...
LiL|aaron
01-10-2007, 01:58 AM
This is vars.php
<?php
$login_user = 'admin';
$login_pass = 'admin';
?>
Nothing i would call sensitive its just temp
NightShift58
01-10-2007, 02:02 AM
} elseif (($action == 1) || ($_SESSION['auth'] = 1)) {
$auser = $_POST['username'];
$apass = $_POST['pass'];
$language = $_POST['lang'];I think this is the problem. At some point, $_SESSION['1'] may be set but not $_POST['username'], as this is only the case once, after the login "page". These 3 lines overwrite $auser, $apass and $language with undefined values.
You may need to change this to:} elseif (($action == 1) || ($_SESSION['auth'] = 1)) {
if (isset($_POST['username']) {
$auser = $_POST['username'];
$apass = $_POST['pass'];
$language = $_POST['lang'];
} else {
$auser = $_SESSION['username'];
$apass = $_SESSION['pass'];
$language = $_SESSION['lang'];
}
LiL|aaron
01-10-2007, 02:02 AM
Heres one of the included pages used here:
<a class="square" href="index.php?id=Home"><font face="Tahoma" size="-1"><? echo "".$lang['EditHome'].""; ?></font></a><br>
and
case "Home":
include "content/Homepage.php";
break;
So this is the Homepage.php
<?php
include("/home/orion/public_html/sIte/admin/editor/fckeditor.php") ;
include("/home/orion/public_html/sIte/db.php") ;
?>
<font face="Tahoma" color="#FFFFFF" size="-1"><strong>Homepage</strong><BR>
Use this feature to update the current page.
<BR><BR>
<hr color="ffffff" size="1">
<BR>
<strong>Edit Page</strong>
<BR>
<form action="content/Homepage_Save.php" method="post">
<?php
$query = "SELECT homepage FROM site_eng";
$result = mysql_query($query);
$r = mysql_fetch_array($result);
$homepage_eng = $r['homepage'] ;
$sBasePath = $_SERVER['PHP_SELF'] ;
$sBasePath = substr( $sBasePath, 0, strpos( $sBasePath, "/sIte/admin/editor/" ) ) ;
$oFCKeditor = new FCKeditor('FCKeditor1') ;
$oFCKeditor->BasePath = '/sIte/admin/editor/' ;
$oFCKeditor->Value = $homepage_eng;
$oFCKeditor->Create() ;
?>
<br>
<input type="submit" value="Submit">
</form>
</font>
NightShift58
01-10-2007, 02:06 AM
We crossed each other... See my previous post. I think that's your problem.
NightShift58
01-10-2007, 02:07 AM
Homepage.php is okay. It doesn't change any of your login values.
LiL|aaron
01-10-2007, 02:08 AM
Still the same mate, take a look here and your see what its doing
http://www.stargatetew.com/sIte/admin/index.php
user and pass is admin
NightShift58
01-10-2007, 02:24 AM
Change your background color to white or yellow...
There's a big error message on the startup screen that can't be seen because it black-on-black.
NightShift58
01-10-2007, 02:26 AM
Warning: main(blank.php): failed to open stream: No such file or directory in /home/orion/public_html/sIte/admin/index.php on line 130
Warning: main(): Failed opening 'blank.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/orion/public_html/sIte/admin/index.php on line 13
NightShift58
01-10-2007, 02:29 AM
[ ] Parent Directory 10-Jan-2007 08:02 -
[ ] Affiliates.php 10-Jan-2007 01:20 1k
[ ] Affiliates_Save.php 08-Jan-2007 19:52 1k
[ ] DevTeam.php 10-Jan-2007 01:20 1k
[ ] DevTeam_Save.php 08-Jan-2007 19:52 1k
[ ] Downloads.php 10-Jan-2007 01:20 1k
[ ] Downloads_Save.php 08-Jan-2007 19:52 1k
[ ] Downloads_Upload.php 06-Jan-2007 07:14 4k
[ ] Homepage.php 10-Jan-2007 04:08 1k
[ ] Homepage_Save.php 08-Jan-2007 20:24 1k
[ ] Information.php 10-Jan-2007 01:24 1k
[ ] Information_Save.php 08-Jan-2007 19:53 1k
[ ] Media.php 10-Jan-2007 01:25 1k
[ ] Media_Save.php 08-Jan-2007 19:53 1k
[ ] Media_Upload.php 06-Jan-2007 11:28 4k
[ ] Poll.php 10-Jan-2007 01:27 3k
[ ] Recruitment.php 10-Jan-2007 01:27 1k
[ ] Recruitment_Save.php 08-Jan-2007 19:53 1k This is your content directory but no page "blank.php" and since that's the first page, your script breaks and your variables don't get set...
LiL|aaron
01-10-2007, 02:29 AM
Aww i just put that there till i did something for it...
But made no difference
NightShift58
01-10-2007, 02:33 AM
Can you post a copy of index.php again, the way it is now?
LiL|aaron
01-10-2007, 02:36 AM
YEah sure
<?php
session_start();
?>
<style type="text/css">
.square{background-image:url(images/square.gif); background-position:left; background-repeat:no-repeat; padding-left:7px; line-height:18px; color:#eaf4fe; text-decoration:none}
.square:hover{color:#c8ef08; text-decoration:underline}
</style>
<body bgcolor="#000000">
<title>Admin</title>
<?php
include 'vars.php';
$action = $_POST['action'];
if (!isset($action)) {
?>
<form id="login" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<font color="#FFFFFF" face="Tahoma" size="-1" style="padding-top: 4px;"><b>Admin Login</b> </font><BR><BR>
<input type="hidden" name="action" value="1">
<table border="0" cellpadding="2" cellspacing="2">
<tr>
<td align="right" valign="top" style="padding-top: 4px;"><font color="#FFFFFF" face="Tahoma" size="-1"><b>Username:</b> </font></td>
<td valign="top">
<input type="Text" name="username" id="username" size="17">
</td>
</tr>
<tr>
<td align="right" valign="top" style="padding-top: 4px;"><font color="#FFFFFF" face="Tahoma" size="-1"><b>Password:</b> </font></td>
<td valign="top">
<input type="password" name="pass" id="pass" size="17" title="Password is case-sensitive!">
</td>
</tr>
<tr>
<td align="right" valign="top" style="padding-top: 4px;"><font color="#FFFFFF" face="Tahoma" size="-1"><b>Language:</b> </font></td>
<td valign="top">
<select name="lang"><option value="eng" selected>English<option value="sp">Spanish<option value="fr">French<option value="de">German</select>
</td>
</table>
<input type="submit" name="submit" value="Submit"><br><br>
</form>
<?
} elseif (($action == 1) || ($_SESSION['auth'] == 1)) {
if (isset($_POST['username'])) {
$auser = $_POST['username'];
$apass = $_POST['pass'];
$language = $_POST['lang'];
} else {
$auser = $_SESSION['username'];
$apass = $_SESSION['pass'];
$language = $_SESSION['lang'];
}
if ($auser == $login_user && $apass == $login_pass) {
$_SESSION['auth'] = 1;
$_SESSION['user'] = $auser;
include ('/home/orion/public_html/sIte/language/lang_'.$language.'.php');
?>
<table align="center" width="100%" border="0">
<tr>
<td align="center"><font face="Tahoma" color="#FFFFFF" size="-2"><strong><? echo "".$lang['Welcome']." ".$_SESSION['user']."";?>, <? echo "".$lang['Admin'].""; ?></strong></font><br></td>
</tr>
</table>
<table width="100%" align="center" border="0">
<tr>
<td width="15%" valign="top">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><font face="Tahoma" size="-1" color="#c8ef08"><strong><? echo "".$lang['Navigation'].""; ?></strong></font></td>
</tr>
</table>
<a class="square" href="index.php?id=Home"><font face="Tahoma" size="-1"><? echo "".$lang['EditHome'].""; ?></font></a><br>
<a class="square" href="index.php?id=Downloads"><font face="Tahoma" size="-1"><? echo "".$lang['EditDownloads'].""; ?></font></a><br>
<a class="square" href="index.php?id=Information"><font face="Tahoma" size="-1"><? echo "".$lang['EditInfo'].""; ?></font></a><br>
<a class="square" href="index.php?id=DevTeam"><font face="Tahoma" size="-1"><? echo "".$lang['EditTeam'].""; ?></font></a><br>
<a class="square" href="index.php?id=Recruitment"><font face="Tahoma" size="-1"><? echo "".$lang['EditRecruit'].""; ?></font></a><br>
<a class="square" href="index.php?id=Media"><font face="Tahoma" size="-1"><? echo "".$lang['EditMedia'].""; ?></font></a><br>
<a class="square" href="index.php?id=Affiliates"><font face="Tahoma" size="-1"><? echo "".$lang['EditAffil'].""; ?></font></a><br>
<a class="square" href="index.php?id=Poll"><font face="Tahoma" size="-1"><? echo "".$lang['EditPoll'].""; ?></font></a><br>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><font face="Tahoma" size="-1" color="#c8ef08"><strong><? echo "".$lang['Logout'].""; ?></strong></font></td>
</tr>
</table>
<a class="square" href="index.php?id=Logout"><font face="Tahoma" size="-1"><? echo "".$lang['Logout'].""; ?></font></a></td>
</td>
<td width="70%" valign="top">
<?php
switch($_GET['id']){
case "Home":
include "content/Homepage.php";
break;
case "Downloads":
include "content/Downloads.php";
break;
case "Information":
include "content/Information.php";
break;
case "DevTeam":
include "content/DevTeam.php";
break;
case "Recruitment":
include "content/Recruitment.php";
break;
case "Media":
include "content/Media.php";
break;
case "Affiliates":
include "content/Affiliates.php";
break;
case "Poll":
include "content/Poll.php";
break;
case "Logout":
session_destroy();
echo "<font face='Tahoma' color='#FFFFFF' size='-1'>".$lang['Loggedout']."</font>";
break;
default:
include "content/blank.php";
}
?>
</td>
</tr>
</table>
</body>
<?
} else {
echo '<font face="Tahoma" size="-1">Login Failed</font>';
}
}
?>
NightShift58
01-10-2007, 02:47 AM
can you add this this at the bottom of index.php, right before the ?>print "<pre>POST";
print_r($_POST);
print "</pre>";
print "<pre>SESSION";
print_r($_SESSION);
print "</pre>";
print "<pre>VARS";
print $auser . "<br>";
print $apass . "<br>";
print $language . "<br>";
print $login_user . "<br>";
print $login_pass . "<br>";
print "</pre>";
LiL|aaron
01-10-2007, 02:49 AM
yea it come up with
POSTArray
(
)
SESSIONArray
(
[auth] => 1
[user] => admin
)
VARSadminadmin
NightShift58
01-10-2007, 02:51 AM
Please copy the same stuff at the top of the script, right after sessoin_start()
LiL|aaron
01-10-2007, 02:52 AM
Then after logging
POSTArray
(
[action] => 1
[username] => admin
[pass] => admin
[lang] => eng
[submit] => Submit
)
SESSIONArray
(
[auth] => 1
[user] => admin
)
VARS
admin
admin
eng
admin
admin
NightShift58
01-10-2007, 02:56 AM
Please copy the same stuff at the top of the script, right after sessoin_start()
LiL|aaron
01-10-2007, 03:07 AM
Before logging in
POSTArray
(
)
SESSIONArray
(
[auth] => 1
[user] => admin
)
VARS
after logging in
POSTArray
(
[action] => 1
[username] => admin
[pass] => admin
[lang] => eng
[submit] => Submit
)
SESSIONArray
(
[auth] => 1
[user] => admin
)
VARS
NightShift58
01-10-2007, 03:17 AM
Can you add this at the top;print "<pre>GET";
print_r($_GET);
print "</pre>";
NightShift58
01-10-2007, 03:24 AM
The only thing that works is a failed login.
Can I see the lang_eng.php file?
LiL|aaron
01-10-2007, 03:31 AM
Before:
GETArray
(
)
After:
GETArray
(
)
lang_eng.php
<?php
$langfile = 'eng';
//SITE
$lang['SHome'] = 'Home';
$lang['RMedia'] = 'Random Media';
$lang['RPoll'] = 'Poll';
$lang['PollVote'] = 'Your Votes Please';
$lang['NoVotes'] = 'Number of votes:';
$lang['ThxVoting'] = 'Thanks for Voting!';
$lang['Vote'] = 'Vote';
$lang['PollRes'] = 'Poll Results';
$lang['SAffil'] = 'Affiliates';
$lang['SDown'] = 'Downloads';
$lang['SInfo'] = 'Information';
$lang['STeam'] = 'Dev Team';
$lang['SRecruit'] = 'Recruitment';
$lang['SMedia'] = 'Media';
//ADMIN
$lang['Welcome'] = 'Welcome ';
$lang['Admin'] = ', Your The Admin In Control!';
$lang['Navigation'] = 'Navigation';
$lang['Logout'] = 'Logout';
$lang['Loggedout'] = 'You Are No Longer Logged In!';
$lang['EditHome'] = 'Edit Homepage';
$lang['Home'] = 'Homepage';
$lang['HomeD'] = 'Use this feature to update the current page.';
$lang['EditDownloads'] = 'Edit Downloads';
$lang['Downloads'] = 'Downloads';
$lang['DownloadsD'] = 'Use this feature to upload new downloads or update the current page.';
$lang['EditInfo'] = 'Edit Information';
$lang['Info'] = 'Information';
$lang['InfoD'] = 'Use this feature to update the current page.';
$lang['EditTeam'] = 'Edit Dev Team';
$lang['Team'] = 'Dev Team';
$lang['TeamD'] = 'Use this feature to update the current page.';
$lang['EditRecruit'] = 'Edit Recruitment';
$lang['Recruit'] = 'Recruitment';
$lang['RecruitD'] = 'Use this feature to update the current page. ';
$lang['EditMedia'] = 'Edit Media';
$lang['Media'] = 'Media';
$lang['MediaD'] = 'Use this feature to upload new media or update the current page.';
$lang['EditAffil'] = 'Edit Affiliates';
$lang['Affil'] = 'Affiliates';
$lang['AffilD'] = 'Use this feature to update the current page.';
$lang['UploadFile'] = 'Upload File';
$lang['Upload'] = 'Select File To Upload:';
$lang['Filesize'] = '(Only files that are smaller than 100000 bytes will be uploaded)';
$lang['UploadS'] = 'Upload Files';
$lang['UpInfo'] = 'Upload Information';
$lang['UpName'] = 'File Name';
$lang['UpSize'] = 'Size';
$lang['UpType'] = 'Type';
$lang['UpStat'] = 'Upload';
$lang['UpURL'] = 'URL';
$lang['UpMore'] = 'Upload More Files';
$lang['EditPage'] = 'Edit Page';
$lang['Submit'] = 'Submit';
$lang['Saved'] = 'Page Saved';
$lang['Preview'] = 'Preview Submitted Page';
$lang['EditPoll'] = 'Edit Poll';
$lang['PollAdmin'] = 'Poll Admin';
$lang['PollD'] = 'Use this feature to review or update the current poll.';
$lang['Items'] = 'Number of Items:';
$lang['PollQ'] = 'Poll Question:';
$lang['PollReady'] = 'Poll ready to go!';
$lang['CurPoll'] = 'Current Poll:';
$lang['PollErr1'] = 'Enter a poll name';
$lang['PollErr2'] = 'Enter some poll items.';
$lang['PollS'] = 'Ok';
?>
NightShift58
01-10-2007, 03:42 AM
I'm running a watered down version on my server.
I can't get to go thru the SWITCH...
LiL|aaron
01-10-2007, 04:06 AM
YEa thats what we are getting on my server... really doing my head in... i already spent 2 hours on it before posting it on here.
NightShift58
01-10-2007, 04:18 AM
Please change this line:if (!isset($action)) {to:if (!isset($_GET['id']) AND !isset($action)) {
NightShift58
01-10-2007, 04:21 AM
There's been a couple of errors and errors messages that ended up sidetracking. us. But the problem was what wrote a looooooooooooooong time ago. On the first two runs, everything is ok but on the third run, $action is back to null and it goes to the form.
I was playing around with the $_GET variable but in the wrong place and it's 4:20 a.m. and my eyes are barely open...
Aaaarrrrgh.............
NightShift58
01-10-2007, 04:23 AM
Everything seems to be working...
I just uloaded an image and that seems to have worked as well...
NightShift58
01-10-2007, 04:26 AM
Dont' forget to change user/pass...
LiL|aaron
01-10-2007, 06:03 AM
Hi mate,
I really do appriecate your help, but i read around the forums and php.net and got idea's and basically brush up on my coding and i actually ended up getting it working!
heres my final code.
<?php
session_start();
include 'vars.php';
$languages = array('eng', 'sp', 'fr', 'de');
$message = '';
if(!isset($_SESSION['lang'])) {
$_SESSION['lang'] = 'eng';
} else {
if (!in_array($_SESSION['lang'], $languages)) {
$_SESSION['lang'] = 'eng';
}
}
function isLoged() {
if(isset($_SESSION['auth']) && isset($_SESSION['user'])) {
if ($_SESSION['auth'] == '1') {
return true;
}
}
return false;
}
if (isset($_POST['btnLogin'])) {
if (($_POST['username'] == $login_user) && ($_POST['password'] == $login_pass)) {
$_SESSION['auth'] = '1';
$_SESSION['user'] = $_POST['username'];
$_SESSION['lang'] = $_POST['lang'];
} else {
$message = '<font face="Tahoma" size="-1">Login Failed</font>';
}
}
include ('/home/orion/public_html/sIte/language/lang_' . $_SESSION['lang'] . '.php');
?>
<html>
<head>
<title>Admin</title>
<style type="text/css">
.square {
background-image: url(images/square.gif);
background-position:left;
background-repeat: no-repeat;
padding-left:7px;
line-height:18px;
color: #eaf4fe;
text-decoration:none
}
.square:hover {
color:#c8ef08;
text-decoration: underline
}
</style>
</head>
<body bgcolor="#000000" text="#FFFFFF">
<?php
echo $message;
if (!isLoged()) {
?>
<form id="login" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<font color="#FFFFFF" face="Tahoma" size="-1" style="padding-top: 4px;"><b>Admin Login</b> </font><BR><BR>
<table border="0" cellpadding="2" cellspacing="2">
<tr>
<td align="right" valign="top" style="padding-top: 4px;"><font color="#FFFFFF" face="Tahoma" size="-1"><b>Username:</b> </font></td>
<td valign="top"><input type="text" name="username" size="17"></td>
</tr>
<tr>
<td align="right" valign="top" style="padding-top: 4px;"><font color="#FFFFFF" face="Tahoma" size="-1"><b>Password:</b> </font></td>
<td valign="top"><input type="password" name="password" size="17" title="Password is case-sensitive!"></td>
</tr>
<tr>
<td align="right" valign="top" style="padding-top: 4px;"><font color="#FFFFFF" face="Tahoma" size="-1"><b>Language:</b> </font></td>
<td valign="top"><select name="lang"><option value="eng" selected>English<option value="sp">Spanish<option value="fr">French<option value="de">German</select></td>
</table>
<input type="submit" name="btnLogin" value="Submit"><br><br>
</form>
<?
} elseif (isLoged()) {
?>
<table align="center" width="100%" border="0">
<tr>
<td align="center"><font face="Tahoma" color="#FFFFFF" size="-2"><strong><?=$lang['Welcome'] . " " . $_SESSION['user'];?>, <?=$lang['Admin'];?></strong></font><br/></td>
</tr>
</table>
<table width="100%" align="center" border="0">
<tr>
<td width="15%" valign="top">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><font face="Tahoma" size="-1" color="#c8ef08"><strong><?=$lang['Navigation'];?></strong></font></td>
</tr>
</table>
<a class="square" href="index.php?id=Home"><font face="Tahoma" size="-1"><?=$lang['EditHome'];?></font></a><br>
<a class="square" href="index.php?id=Downloads"><font face="Tahoma" size="-1"><?=$lang['EditDownloads'];?></font></a><br>
<a class="square" href="index.php?id=Information"><font face="Tahoma" size="-1"><?=$lang['EditInfo'];?></font></a><br>
<a class="square" href="index.php?id=DevTeam"><font face="Tahoma" size="-1"><?=$lang['EditTeam'];?></font></a><br>
<a class="square" href="index.php?id=Recruitment"><font face="Tahoma" size="-1"><?=$lang['EditRecruit'];?></font></a><br>
<a class="square" href="index.php?id=Media"><font face="Tahoma" size="-1"><?=$lang['EditMedia'];?></font></a><br>
<a class="square" href="index.php?id=Affiliates"><font face="Tahoma" size="-1"><?=$lang['EditAffil'];?></font></a><br>
<a class="square" href="index.php?id=Poll"><font face="Tahoma" size="-1"><?=$lang['EditPoll'];?></font></a><br>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><font face="Tahoma" size="-1" color="#c8ef08"><strong><?=$lang['Logout'];?></strong></font></td>
</tr>
</table>
<a class="square" href="index.php?id=Logout"><font face="Tahoma" size="-1"><?=$lang['Logout'];?></font></a></td>
</td>
<td width="70%" valign="top">
<?php
switch($_GET['id']) {
case "Home": include("content/Homepage.php"); break;
case "Downloads": include("content/Downloads.php"); break;
case "Information": include("content/Information.php"); break;
case "DevTeam": include("content/DevTeam.php"); break;
case "Recruitment": include("content/Recruitment.php"); break;
case "Media": include("content/Media.php"); break;
case "Affiliates": include("content/Affiliates.php"); break;
case "Poll": include("content/Poll.php"); break;
case "Logout":
session_destroy();
echo '<font face="Tahoma" color="#FFFFFF" size="-1">' . $lang['Loggedout'] . '</font>';
echo '<script type="text/javascript">setTimeout("document.location=\'index.php\'",2000);</script>';
break;
default: include("content/blank.php"); break;
}
?>
</td>
</tr>
</table>
<?
}
?>
</body>
</html>
Thanks again for the help!
P.S i have changed the password :)
LiL|aaron
01-10-2007, 06:18 AM
How do i make this thread resolved...
NightShift58
01-10-2007, 12:19 PM
You're welcome!
fadia85
01-12-2007, 04:23 AM
hey,
i noticed that youhave a session_destroy func in our code.. i think that is the reason.. you only havea asession destroy on you logout page.
i hope i helped...
Hi,
I seem to be having problems with my login script or the sessions, because i can login no problem but when i try accessing a page, it goes back to the login screen.
Heres my code:
<?php
session_start();
?>
<style type="text/css">
.square{background-image:url(images/square.gif); background-position:left; background-repeat:no-repeat; padding-left:7px; line-height:18px; color:#eaf4fe; text-decoration:none}
.square:hover{color:#c8ef08; text-decoration:underline}
</style>
<body bgcolor="#000000">
<title>Admin</title>
<?php
include 'vars.php';
$action = $_POST['action'];
if (!isset($action)) {
?>
<form id="login" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<font color="#FFFFFF" face="Tahoma" size="-1" style="padding-top: 4px;"><b>Admin Login</b> </font><BR><BR>
<input type="hidden" name="action" value="1">
<table border="0" cellpadding="2" cellspacing="2">
<tr>
<td align="right" valign="top" style="padding-top: 4px;"><font color="#FFFFFF" face="Tahoma" size="-1"><b>Username:</b> </font></td>
<td valign="top">
<input type="Text" name="username" id="username" size="17">
</td>
</tr>
<tr>
<td align="right" valign="top" style="padding-top: 4px;"><font color="#FFFFFF" face="Tahoma" size="-1"><b>Password:</b> </font></td>
<td valign="top">
<input type="password" name="pass" id="pass" size="17" title="Password is case-sensitive!">
</td>
</tr>
<tr>
<td align="right" valign="top" style="padding-top: 4px;"><font color="#FFFFFF" face="Tahoma" size="-1"><b>Language:</b> </font></td>
<td valign="top">
<select name="lang"><option value="eng" selected>English<option value="sp">Spanish<option value="fr">French<option value="de">German</select>
</td>
</table>
<input type="submit" name="submit" value="Submit"><br><br>
</form>
<?
} elseif (($action == 1) || ($_SESSION['auth'] = 1)) {
$auser = $_POST['username'];
$apass = $_POST['pass'];
$language = $_POST['lang'];
if ($auser == $login_user && $apass == $login_pass) {
$_SESSION['auth'] = 1;
$_SESSION['user'] = $auser;
include ('/home/orion/public_html/sIte/language/lang_'.$language.'.php');
?>
<table align="center" width="100%" border="0">
<tr>
<td align="center"><font face="Tahoma" color="#FFFFFF" size="-2"><strong><? echo "".$lang['Welcome']." ".$_SESSION['user']."";?>, <? echo "".$lang['Admin'].""; ?></strong></font><br></td>
</tr>
</table>
<table width="100%" align="center" border="0">
<tr>
<td width="15%" valign="top">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><font face="Tahoma" size="-1" color="#c8ef08"><strong><? echo "".$lang['Navigation'].""; ?></strong></font></td>
</tr>
</table>
<a class="square" href="index.php?id=Home"><font face="Tahoma" size="-1"><? echo "".$lang['EditHome'].""; ?></font></a><br>
<a class="square" href="index.php?id=Downloads"><font face="Tahoma" size="-1"><? echo "".$lang['EditDownloads'].""; ?></font></a><br>
<a class="square" href="index.php?id=Information"><font face="Tahoma" size="-1"><? echo "".$lang['EditInfo'].""; ?></font></a><br>
<a class="square" href="index.php?id=DevTeam"><font face="Tahoma" size="-1"><? echo "".$lang['EditTeam'].""; ?></font></a><br>
<a class="square" href="index.php?id=Recruitment"><font face="Tahoma" size="-1"><? echo "".$lang['EditRecruit'].""; ?></font></a><br>
<a class="square" href="index.php?id=Media"><font face="Tahoma" size="-1"><? echo "".$lang['EditMedia'].""; ?></font></a><br>
<a class="square" href="index.php?id=Affiliates"><font face="Tahoma" size="-1"><? echo "".$lang['EditAffil'].""; ?></font></a><br>
<a class="square" href="index.php?id=Poll"><font face="Tahoma" size="-1"><? echo "".$lang['EditPoll'].""; ?></font></a><br>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><font face="Tahoma" size="-1" color="#c8ef08"><strong><? echo "".$lang['Logout'].""; ?></strong></font></td>
</tr>
</table>
<a class="square" href="index.php?id=Logout"><font face="Tahoma" size="-1"><? echo "".$lang['Logout'].""; ?></font></a></td>
</td>
<td width="70%" valign="top">
<?php
switch($_GET['id']){
case "Home":
include "content/Homepage.php";
break;
case "Downloads":
include "content/Downloads.php";
break;
case "Information":
include "content/Information.php";
break;
case "DevTeam":
include "content/DevTeam.php";
break;
case "Recruitment":
include "content/Recruitment.php";
break;
case "Media":
include "content/Media.php";
break;
case "Affiliates":
include "content/Affiliates.php";
break;
case "Poll":
include "content/Poll.php";
break;
case "Logout":
session_destroy();
echo "<font face='Tahoma' color='#FFFFFF' size='-1'>".$lang['Loggedout']."</font>";
break;
default:
include "blank.php";
}
?>
</td>
</tr>
</table>
</body>
<?
} else {
echo '<font face="Tahoma" size="-1">Login Failed</font>';
}
}
?>
Thanks for any help.