View Full Version : Can't login after loggin out!!!!!

11-03-2007, 08:41 PM
Well, i don't know what is the problem in my code
after creating an account ,am logged in and i can access my page
but after logging out i can't log in again!!
i don't know why??????

<?php session_start();
require "forum.inc.php";
$mainpage="<a href='main.php'>Proceed to the main page</a>";
$logoutpage="<a href='welcomepage.php'>Logout</a>";

if($username && $password){
setup_page("Already logged in","Already logged in");
echo $username.",You are already logged in</br></br>";
echo $mainpage."</br>";
echo $logoutpage;
$query=mysqli_query($conn,"select * from users where name='".$username."'
and password=password('".$password."')");
if(!$query)fail("database query faild",true);
echo $mainpage."</br>";
echo $logoutpage;
setup_page("login","Invalid login");
echo "Your username & password doesnt appear to match ,try again";
elseif($username || $password){
setup_page("Invalid login","Invalid login");
echo "Please fill in both fields";

echo "Please entr your details to login";
<form action="forumlogin.php" method="post">
<input type="text" name="username" maxlength="20" size="20">
<input type="password" name="password" maxlength="20" size="20">
<input type="submit" value="Login">
<a href="forumregister.php">Register New User</a>

11-03-2007, 09:35 PM
it works only when i omit the password portion

and password=password('".$password."')

11-03-2007, 09:37 PM
Where do you define $username and $password? If you don't define them and register_globals is on then it will come as a post variable however having register_globals on is a security risk. If you don't have them defined try change this

require "forum.inc.php";
$mainpage="<a href='main.php'>Proceed to the main page</a>";
$logoutpage="<a href='welcomepage.php'>Logout</a>";
to this

require "forum.inc.php";
$mainpage="<a href='main.php'>Proceed to the main page</a>";
$logoutpage="<a href='welcomepage.php'>Logout</a>";
$username= $_POST['username'];
$password= $_POST['password'];
Now you may need to change your if statement because I believe the $_POST array always returns true so something like this instead

if($username != '' && $password != ''){

11-03-2007, 10:06 PM
thnxxxx alot
it worked
my problem that i was putting the password in the database as char(12) and it was encodes and each time i register an account it gives the first 12 letter the same encoding values
for example
username:one password=123456e
username:two password=123456e
so i changed it to char(50)
to make it look like that
username:one password=123456eertubdf
username:two password=123456eerertyu

its all about database encoding

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum