Hi
Ive loooooooooooked and looooooooooooked and loooooooooooked but no sign of whats wrong! Ive tried removing the session_destroy() calls but that didnt work. I tried taking out some unneeded bits but no joy there either. Sooooo.... heres allllllll te code from core.php which is called using a require function as the first bit of php on each page:
<?php
session_start();
$command = $_GET['command'];
$user = $_POST['user'];
$pass = $_POST['pass'];
$passconf = $_POST['passconf'];
$email = $_POST['email'];
$firstname = $_POST['firstname'];
$lastname = $_POST['lastname'];
$avatar = $_POST['user'];
$description = $_POST['description'];
$comment = $_POST['comment'];
$idgrab = $_POST['id'];
$me = $_SERVER['PHP_SELF'];
$date = date("d/m/Y");
global $text;
global $text2;
$conn = @mysql_connect("BLANKED", "BLANKED", "BLANKED")
or die("Connection to MySQL failed because ".mysql_error());
$rs = @mysql_select_db( "BLANKED", $conn)
or die("Couldnt access database because ".mysql_error());
function query($query)
{
$res = @mysql_query( $query)
or die("Couldnt execute query because ".mysql_error());
return $res;
}
if($command == "lostpass")
{
$text2 = "Enter your email address below to get your password sent to your email address:<bR>
<form action=\"$me?command=lostsend\" method=\"post\">
<input type=\"text\" name=\"email\" value=\"Email address\">
<input type=\"submit\" value=\"Send pass!\">
</form>";
}
if($command == "signup")
{
if($pass == $passconf)
{
if((!$user) or (!$pass) or (!$passconf) or (!$email) or (!$firstname) or (!lastname))
{
$text2 = "Oops, fill in all the fields!";
}
else
{
$res = query("select * from npass where email=\"$email\"");
$num = mysql_numrows( $res );
if($num > 0)
{
$text2 = "This e-mail address has an account. Please do not create multis. Well, you err cant so up yours :-p.";
}
else
{
$res = query("select * from npass where users=\"$user\"");
$num = mysql_numrows( $res );
if($num > 0)
{
$text2 = "This username has an account. Please try again!";
}
else
{
$res = query("insert into npass (user, password, passenc, date, email, firstname, lastname, id, active, access, comment, avatar, logins, description, posts) values (\"$user\", \"$pass\", password(\"pass\"), \"$date\", \"$email\", \"firstname\", \"lastname\", \"0\", \"0\", \"0\", \"$comment\", \"$avatar\", \"0\", \"$description\", \"0\")");
}
}
}
}
else
{
$text2 = "Passwords need to match!";
}
}
if($command == "lostsend")
{
if(!$email)
{
$text2 = "You need to enter your address to have your password sent!";
}
else
{
$res = query("select * from npass where email=\"$email\"");
$num = mysql_numrows( $res );
if($num > 0)
{
$stuff = mysql_fetch_array($res);
mail( $email, "Your npass password", "Dear user,/n Here is your password: ".$stuff['pass']."/nYours, the nPass team" )
or die('Failed to send message - unresolveable error');
$text2 = "Pass sent!";
}
else
{
$text2 = "E-Mail address not found, try again!";
}
}
}
if($command == "logout")
{
session_destroy();
$text2 = "Logout successfull";
}
if($command == "login")
{
if((!$user) or (!$pass))
{$text2 = "Fill in all fields please!";}
else
{
$res = query("select * from npass where user=\"$user\" and passenc=password(\"$pass\")");
$num = mysql_numrows( $res );
if($num != 0)
{
$stuff = mysql_fetch_array($res);
$_SESSION['user'] = $stuff['user'];
$_SESSION['avatar'] = $stuff['avatar'];
$_SESSION['passenc'] = $stuff['passenc'];
$_SESSION['comment'] = $stuff['comment'];
$_SESSION['description'] = $stuff['description'];
$_SESSION['email'] = $stuff['email'];
$_SESSION['name'] = $stuff['firstname'];
$_SESSION['access'] = $stuff['access'];
$_SESSION['usid'] = $stuff['id'];
$_SESSION['logins'] = $stuff['logins'];
$_SESSION['date'] = $stuff['date'];
$_SESSION['active'] = $stuff['active'];
$text3= $_SESSION['user'].$_SESSION['avatar'].$_SESSION['passenc'].$_SESSION['comment'].$_SESSION['description'].$_SESSION['email'].$_SESSION['name'].$_SESSION['access'].$_SESSION['usid'].$_SESSION['logins'].$_SESSION['date'].$_SESSION['active'];
if($_SESSION['active'] == 1)
{
$text2 = "Login Successful!";
}
else
{
$text2 = "Your account is inactive! You must activate it by clicking the link in your email first!"; session_destroy();
}
}
else
{
$text2 = "Incorrect user name and/or password! Please Login again";
}
}
}
if($command=="confirm")
{
if(!$idgrab)
{
$text2 = "Only visit here with a real account activation key please";
}
else
{
query("update npass set active = \"1\" where id = \"$idgrab\"");
$text2("Your account is now active! You may now login.");
}
}
if(!isset($_SESSION['user']))
{
$text = "You aren't logged in. Click <a href=\"login.php\">here</a> to log in";
}
else
{
$sql = "select * from npass where user = \"".$_SESSION['user']."\" and passenc = \"".$_SESSION['passenc']."\"";
$res = query($sql);
$num = mysql_numrows( $res );
if($num != 0)
{
$text = "Welcome back ".$_SESSION['name'].". You are logged in. Click <a href=\"index.php?command=logout\">here</a> to logout";
}
else
{
$text = "Authentication failed! Please Login again"; session_destroy();
}
}
if(isset($_SESSION['user']))
{
$img = "logout.gif";
$link = "login2.php?command=logout";
}
else
{
$img = "login.gif";
$link = "login.php";
}
$head='
<meta name="author" content="Tom Hands - tom@n-fusion.co.uk">
<meta name="content" content="N-Pass, the N-Fusion authentication system">
<meta name="generator" content="NOTEPAD :P">
<title>N-Pass - The N-Fusion authentication system - '.$me.'</title>
<link href="style.css" type="text/css" rel="stylesheet">
<style type="text/css">
<!--
.form { font-size: 12px; color="white"; background-image: url(bar.png); font-family="tahoma"; border:blue 1px}
-->
</style>';
$top='
<center>
<img src="logo.gif"><br><br>
<img name="links" src="links.gif" width="687" height="32" border="0" usemap="#m_links" alt=""><map name="m_links">
<area shape="rect" coords="569,-1,683,31" href="help.php" alt="" >
<area shape="rect" coords="455,-1,570,31" href="control.php" alt="" >
<area shape="rect" coords="342,-1,457,31" href="sites.php" alt="" >
<area shape="rect" coords="231,-1,344,31" href="register.php" alt="" >
<area shape="rect" coords="116,-1,231,31" href="about.php" alt="" >
<area shape="rect" coords="1,-1,116,31" href="index.php" alt="" ><a href="'.$link.'"><img src="'.$img.'" border="0"></a></center>';
if(!isset($_SESSION['user']))
{
$side='<form action="login2.php?command=login" method="post"><h1>Login</h1><center><p>Username:<br><input type="text" name="user" class="form"><br><Br>Password<br><input class="form" type="password" name="pass"><br>
<br>Forgotten your user name or password? Click <a href="recover.php">here.</a><br><Br><input type="submit" value="Login" class="form"></form><br><a href="resend.php">Resend my confirmation email.</a></center></p>';
}
else
{
$side='<h1>'.$_SESSION['name'].'\'s Control Panel<br>User controls</h1><center><a href="changepass.php"><img src="img/pass.gif" border="0"></a><a href="changeemail.php"><img src="img/email.gif" border="0"></a><br>
<a href="delaccount.php"><img src="img/delete.gif" border="0"></a><a href="changeother.php"><img src="img/other.gif" border="0"></a>';
if($_SESSION['access'] > 0)
{
$side .= '<br><br><h1>Admin only controls</h1><center><a href="chkusers.php"><img src="img/users.gif" border="0"></a>';
}
$side .= '</center>';
}
$bottom='<p>Copyright Tom Hands 2005. All rights reserved. This site is <br><img src="cert.png"></p>';
session_write_close();
print($text.$text2.$text3);
?>
Please not some bits (such as the add user bit) have been left until the sessions work and are incomplete.
Id appreciate any help. If theres still no joy ill do a rewrite around halojoys code (thanks again halojoy)
thanks
toooo<insert several thousand "o"s here>oooom