I am currently making a mafia game which I used a script for.
Atm its almost done.
But Login doesnt work.
Register works fine... BUt login just redirects to the login page again. Its using php obvo. Any ideas?

I am currently making a mafia game which I used a script for.
Atm its almost done.
But Login doesnt work.
Register works fine... BUt login just redirects to the login page again. Its using php obvo. Any ideas?
Post the code
<?php
session_start();
include_once"includes/db_connect.php";
if (strip_tags($_GET['logout']) == "yes"){
session_destroy();
}elseif (isset($_SESSION['username'])){
header("Location: MM.php");
header("Location: choose2.php");
header("Location: choose1.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']));
$select = mysql_query("SELECT * FROM users WHERE online > '$timenow' ORDER by rank desc");
$num = mysql_num_rows($select);
$ip = $REMOTE_ADDR;
///check INFO
$sql = mysql_query("SELECT * FROM users WHERE username='$username' AND password='$password' AND activated='1' 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()+20;
mysql_query("UPDATE users SET online='$timestamp' WHERE username='$username'");
mysql_query("UPDATE users SET l_ip='$ip' WHERE username='$username'");
header("Location: MM.php");
header("Location: loading.php");
} else {
$message= "You could not be logged in.<br />";
}}}
?>
<html>
<head>
<title>Gangsterz Life</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="includes/in1.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
body {
background-image: url();
background-color: #000000;
}
.style3 {color: #FFFFFF; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10px; }
.style4 {
color: #FFFFFF;
font-size: 16px;
font-weight: bold;
}
.style5 {color: #FFFFFF}
-->
</style></head>
<p align="center"><img src="globalM.png" width="575" height="300"></p>
<body onLoad="JSFX_StartEffects()">
<form action="" method="post">
<p> </p>
<table width="599" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#FFFFFF" bgcolor="#333333">
<!--DWLayoutTable-->
<tr> </tr>
<tr>
<td width="178" height="100"> </td>
<td width="402" valign="top" bgcolor="#333333"><table width="591" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="591"> </td>
</tr>
<tr>
<td height="28"><table width="99%" border="0" align="center" cellpadding="2" cellspacing="0" bordercolor="#000000" class=thinline>
<!--DWLayoutTable-->
<tr>
<td width="229" height="20"><div align="center" class="style3">Username:
<input name="username" type="text" id="username">
</div></td>
<td width="236"><div align="center" class="style3">Password:
<input name="password" type="password" id="password">
</div></td>
<td width="78"><p><input type="submit" name="Submit" value="Submit">
</p> </td>
</tr>
</table></td>
</tr>
<tr>
<td> </td>
</tr>
</table>
</td>
<td width="190"></td>
</tr>
<tr>
<td></td>
</table>
<div align="center"><span class="style5"></span>
</td>
</tr>
<a href="register.php"><img src="http://www.lexfest.net/img/register_button.gif" width="102" height="93" border="0"></a>
</div>
</form>
<tr>
<td><table width="607" height="137" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="10" colspan="5"> </td>
</tr>
<tr>
<td height="10" colspan="5"> </td>
</tr>
<tr>
<br>
<td width="607" height="137"> </td>
<tr>
<td><table width="607" height="137" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="97" colspan="5"> </td>
</tr>
wth?PHP Code:}elseif (isset($_SESSION['username'])){
header("Location: MM.php");
header("Location: choose2.php");
header("Location: choose1.php");
Learn PHP before you try and make something.
Smashing scripts together and calling it your own game is cheap.
Tis when you login. You can choose your style of site.
Anyway anyone got ideas?
Lol...
I was under the impression header("Location:"); redirected the user? How can he be directed to 3 places at once using header(); ?PHP Code:header("Location: MM.php");
header("Location: choose2.php");
header("Location: choose1.php");
Yes
When you click Choice 1 it redirects you to my site but one different style and the same for choice 2.
But I cant even get to that as I cant login.
Yeah I think that's the problem, you can only send one header location at a time which maybe causing your problem.
header("Location: MM.php");
header("Location: loading.php");
Start with just one location to begin with, for example loading.php:
header("Location: loading.php");
And get rid of the rest and see if it works.
The next thing is to check the username and password stored in the database, you need to make sure that activated is set to 1 as well. (Simple things can sometimes be the problem)
I am sure it would also be useful if you could post the contents of MM.php and loading.php so we can make sure there is no redirect in there which could be causing the problem, to once logged in then send the user back to the login page.
As has been said you can only use 1 header("Location: "); at any one time so MM.php and loading.php after wont work you have to use 1 or the other. For now just put 1 in then you can sort out choosing which layout or area to go to when you get this bit working.
Last edited by Anzrew; 31-12-2008 at 11:23 AM.
Are you getting header("Location: *") confused with include()?
Want to hide these adverts? Register an account for free!