New Login Script


Posted on 16th Feb 2014 07:03 pm by admin

Hi all, i attempted to create a whole new login script witch isnt working for some reason i dont know why. When i put the users details and then press submit, it just refreshes the page, even when i put the wrong details in it still does the same..


<?php
session_start();
include_once"config.php";
if (strip_tags($_GET['logout']) == "yes"){
session_destroy();
}elseif (isset($_SESSION['username'])){
header("Location: index2.php");
exit();
}

if ($_POST['Submit'] && strip_tags($_POST['username']) && strip_tags($_POST['password'])){
$username = addslashes(strip_tags($_POST['username']));
$password = addslashes(strip_tags($_POST['password']));

$ip = $REMOTE_ADDR;




///check INFO

$sql = mysql_query("SELECT * FROM allmembers WHERE username='$username' AND password='$password' LIMIT 1");


$login_check = mysql_num_rows($sql);
$inf = mysql_fetch_object($sql);
if ($login_check == "0"){
$message="You could not be logged in";
}elseif ($login_check != "0"){


if ($login_check > "0"){
if ($inf->status == "Dead"){
include_once"dead.php";
exit();

}
if ($inf->status == "Banned"){
$encoded=md5(strtolower($username));
header("Location: banned.php?banned=$username&encoded=$encoded");
exit();

}

session_register('username');
$_SESSION['username'] = $inf->username;




$timestamp = time()+60;
mysql_query("UPDATE allmembers SET online='$timestamp' WHERE username='$username'");

mysql_query("UPDATE allmembers SET l_ip='$ip' WHERE username='$username'");



header("Location: members.php");

} else {
$message= "You could not be logged in.<br />";

}}}

$total_regged=mysql_num_rows(mysql_query("SELECT * FROM allmembers"));
$admins=mysql_num_rows(mysql_query("SELECT * FROM allmembers WHERE userlevel='2'"));
$mods=mysql_num_rows(mysql_query("SELECT * FROM allmembers WHERE userlevel='1'"));
$iti=mysql_fetch_object(mysql_query("SELECT * FROM site_stats WHERE id='1'"));
$most=$iti->online;
?>


Thats all the php code for my login system.
Thanks for your help.

No comments posted yet

Your Answer:

Login to answer
219 Like 7 Dislike
Previous forums Next forums
Other forums

Website Direction...
I recently used this code to try and make it so the page loads as http://www.domain.com/ when you ty

Grids not displaying decimals, and behaving differently on different PCs?
Hello,

I coded a relatively simple MII application that allows data from a form to be add

C - Reading a file into a byte array
Hi,

I'm trying to read a file into a byte array in C. I have to use C as this is for a loadru

i want run some web server under the ip sharer
hello i want run some web server under the ip sharer
my ip is floating ip but it doesnt matter

Insert numbers from Barcode scanner into online php page
I have a real big problem, Here is what I'm trying to do. I have a Intermec CN3 handheld computer th

Undefined variable: adHTML
Hello:

While checking my site error logs, I've noticed one repetitive error that fills the lo

Secure pages Sessions vs. Cookies & session_destroy() help
Im new here and new to PHP, I hope you can help me with some questions.

Im writing my web ap

how do i display data on a page from mysql
1 - do i use this code at the top of each of my page i wish to only alow access if there as been a s

Text file to .Dat file Conversion in PHP
Hi All,
Could anybody provide code for Text file to .Dat file Conversion in PHP.

Tha

Format String help
I have a textbox where a person enters an application number. the application number is 10 characte

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash