Jump to content

Login System - Not Working


helpmeplease2

Recommended Posts

index.php

<?php
session_start();
header("Cache-Control: private");
require('includes/config.php');
require('includes/dbconnect.php');

require('includes/logincheck.php');

if(isset($_SESSION['Username']) && isset($_SESSION['Password'])){
include('includes/rightusercp.php');
}else{
include('includes/rightmain.php');
}

$p="includes/" . $_GET['p'] . ".php";
if($_GET['p']==''){
$p="includes/main.php";
}
$c="includes/" . $_GET['c'] . ".php";
if($_GET['c']==''){
$c="includes/home.php";
}
if(isset($_SESSION['Username']) && isset($_SESSION['Password'])){
include($c);
}else{
include($p);
}
?>

 

logincheck.php

<?php
if($_GET['logout']=='y'){
session_unset();
require('config.php');
require('includes/dbconnect.php');
}

if(empty($_SESSION['Username'])){
if(($_POST['Username']!='') && ($_POST['Password']!='')){
$tmpusr=$_POST['Username'];
$results=mysql_query("select Username,Password from members where Username='$tmpusr'");
$row=mysql_fetch_assoc($results);
if (mysql_num_rows($results)==0) {
echo "Invalid Username!";
}elseif($row['Password']!=$_POST['Password']){
echo "Invalid Password!";
}else{
$Username=$_POST['Username'];
$Password=$_POST['Password'];
session_register("Username");
session_register("Password");
$Username=$_SESSION['Username'];
$Password=$_SESSION['Password'];

}

}
}
?>

 

main.php

<table border="0" cellpadding="10" cellspacing="0" align="center"><tr><td align="center">
<div style="width:243px; height:120px;">
<div class="smplan2" align="left">
Members, please sign-in below:
<form action="index.php" method="post" style="padding:0px; margin:0px"><table border="0"><tr><td width="60"><div class="smplan2" align="left">
<b>Username:</b></div></td><td><input class="searchf" type="text" name="Username" size="20"></td></tr><tr><td><div class="smplan2" align="left">
<b>Password:</b></div></td><td><input class="searchf" type="password" name="Password" size="20"></td></tr></table>
<button type="submit" class="buttons">Login</button>
</div>
</div>

 

When I login the page doesn't change. The database is working fine theres just something here thats wrong. Please help.

Link to comment
Share on other sites

ok.... well i just got this next script from a free script website and its not working either:

 

login.php

<?php
require('includes/config.php');
require('includes/dbconnect.php');

if(isset($_COOKIE['apexclan.com']))

{
$username = $_COOKIE['apexclan.com'];
$pass = $_COOKIE['apexclan.com'];
$check = mysql_query("SELECT * FROM members WHERE username = '$username'")or die(mysql_error());
while($info = mysql_fetch_array( $check ))
{
if ($pass != $info['password'])
{
}
else
{
header("Location: members.php");

}
}
}


if (isset($_POST['submit'])) {

if(!$_POST['username'] | !$_POST['pass']) {
die('You did not fill in a required field.');
}

if (!get_magic_quotes_gpc()) {
$_POST['email'] = addslashes($_POST['email']);
}
$check = mysql_query("SELECT * FROM members WHERE username = '".$_POST['username']."'")or die(mysql_error());

$check2 = mysql_num_rows($check);
if ($check2 == 0) {
die('That user does not exist in our database.');
}
while($info = mysql_fetch_array( $check ))
{
$_POST['pass'] = stripslashes($_POST['pass']);
$info['password'] = stripslashes($info['password']);
$_POST['pass'] = md5($_POST['pass']);

if ($_POST['pass'] != $info['password']) {
die('Incorrect password, please try again.');
}

else
{

$_POST['username'] = stripslashes($_POST['username']);
$hour = time() + 3600;
setcookie(ID_my_site, $_POST['username'], $hour);
setcookie(Key_my_site, $_POST['pass'], $hour);

header("Location: members.php");
}
}
}
else
{

?>
<form action="<?php echo $_SERVER['PHP_SELF']?>" method="post">
<table border="0">
<tr><td colspan=2><h1>Login</h1></td></tr>
<tr><td>Username:</td><td>
<input type="text" name="username" maxlength="40">
</td></tr>
<tr><td>Password:</td><td>
<input type="password" name="pass" maxlength="50">
</td></tr>
<tr><td colspan="2" align="right">
<input type="submit" name="submit" value="Login">
</td></tr>
</table>
</form>
<?php
}

?>

 

members.php

<?php
require('includes/config.php');
require('includes/dbconnect.php');

if(isset($_COOKIE['apexclan.com']))
{
$username = $_COOKIE['apexclan.com'];
$pass = $_COOKIE['apexclan.com'];
$check = mysql_query("SELECT * FROM members WHERE username = '$username'")or die(mysql_error());
while($info = mysql_fetch_array( $check ))
{

if ($pass != $info['password'])
{ header("Location: login.php");
}

else
{
echo "<a href='logout.php'>Logout</a>";
}
}
}
else
{
header("Location: login.php");
}
?>

 

When I click to login it just shows me the login box still where it should show me a logout link.

Link to comment
Share on other sites

Might sound silly, and I'm by no means an expert with PHP, but perhaps changing this:

 

<form action="<?php echo $_SERVER['PHP_SELF']?>" method="post">

 

To this:

 

<form action="logincheck.php" method="post">

 

Try that. Like I said I could be entirely wrong, but that's the way my login system works.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.