$_SESSION Problems
- RafliArema
- Posts: 25
- Joined: Tue Jul 12, 2011 11:14 am
$_SESSION Problems
When I'm succesfully logged in, and redirected to parse1.php
But I add some php code on the HEAD:
<?php
include "session.php";
?>
that should works when people click direct links into parse1.php
but ALWAYS, when im login, its always like this:
Not Logged in
Login
What is the problems?
Please help me....
Thanks
But I add some php code on the HEAD:
<?php
include "session.php";
?>
that should works when people click direct links into parse1.php
but ALWAYS, when im login, its always like this:
Not Logged in
Login
What is the problems?
Please help me....
Thanks
- RafliArema
- Posts: 25
- Joined: Tue Jul 12, 2011 11:14 am
Re: $_SESSION Problems
<?php
if (isset($_SESSION['player']))
{
$player=$_SESSION['player'];
}
else
{
echo "Not Logged in <br><br> <A href='login.php'>Login</a>";
exit;
}
?>
if (isset($_SESSION['player']))
{
$player=$_SESSION['player'];
}
else
{
echo "Not Logged in <br><br> <A href='login.php'>Login</a>";
exit;
}
?>
Re: $_SESSION Problems
try this
$_SESSION['player']=$player;
$_SESSION['player']=$player;
Re: $_SESSION Problems
Hahaha we learned that that was a problem the hard way Nexus 

Languages: C++, C#, Javascript + Angular, PHP
Programs: Webstorm 2017, Notepad++, Photoshop
Current Project: HP Destiny
Programs: Webstorm 2017, Notepad++, Photoshop
Current Project: HP Destiny
- RafliArema
- Posts: 25
- Joined: Tue Jul 12, 2011 11:14 am
Re: $_SESSION Problems
@Nexus, it doesn't work..... 

- hallsofvallhalla
- Site Admin
- Posts: 12026
- Joined: Wed Apr 22, 2009 11:29 pm
Re: $_SESSION Problems
you need to make sure you have Session = player in the authenicate page.
- RafliArema
- Posts: 25
- Joined: Tue Jul 12, 2011 11:14 am
Re: $_SESSION Problems
Well, I can post here thought...
Login.php
loguser.php
parse1.php
Anything else?
Login.php
Code: Select all
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link rel="stylesheet" href="gpack/inside.css" type="text/css" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<table width="918" height="64" border="0">
<tr>
<td width="912"> </td>
</tr>
</table>
<table width="920" height="602" border="0">
<tr>
<td width="235" height="598"><table width="200" height="595" border="0">
<tr>
<td height="225"><table width="228" border="1">
<tr>
<td width="218" height="217"><div class="HeadingKecil">
<ul>
<li class="Standard"><a href="index.php" class="HeadingKecil">Halaman Utama</a></li>
<li><a href="help">Instruksi</a></li>
<li><a href="login.php">Login</a></li>
<li><a href="register.php">Daftar</a></li>
<li><a href="about_us.php">Tentang Kami</a></li>
<li><a href="http://xevant.postalboard.com/">Forum</a></li>
<hr align="left"/>
<li><a href="donate.php">Donate</a></li>
<li><a href="help">Xevant on Facebook</a></li>
<li><a href="gallery.php">Galeri</a></li>
<li><a href="jobs.php">Pelamaran</a></li>
</ul>
</div></td>
</tr>
</table></td>
</tr>
<tr>
<td height="364"> </td>
</tr>
</table></td>
<td style="border-left: 2px dotted blue; padding: 5px;" width="605"><table width="595" border="0" class="Standard">
<tr>
<td class="HeadingKecil">Login</td>
</tr>
<tr>
<td class="Standard">Login dengan menggunakan Cookies. Jangan lupa logout setelah selesai bermain, demi keselamatan akun anda sendiri.</td>
</tr>
<tr>
<td height="520"><form action="loguser.php" method="post"><table width="587" border="0">
<tr>
<td width="81">Username:</td>
<td width="307"><label>
<input name="player" type="text" id="player" maxlength="7" />
</label></td>
</tr>
<tr>
<td>Password:</td>
<td><label>
<input type="password" name="password" id="password" />
</label></td>
</tr>
<tr>
<td height="53"><div align="center"><img src="images/captcha.php" /></div></td>
<td><table width="200" border="0">
<tr>
<td>Captcha:</td>
</tr>
<tr>
<td><label>
<input type="text" name="captcha" id="captcha" />
</label></td>
</tr>
</table>
<p>
<label>
<input type="submit" name="submit" id="submit" value="Login" />
</label>
|
<label>
<input type="reset" name="reset" id="reset" value="Clear Fields" />
</label>
</p></td>
</tr>
<tr>
<td height="361"></td>
<td></td>
</tr>
</table></form></td>
</tr>
</table></td>
<td style="border-left: 2px dotted blue; padding: 5px;" width="66"> </td>
</tr>
</table>
<p> </p>
</body>
</html>
Code: Select all
<?php
include_once 'connect.php';
session_start();
if (isset($_POST['submit']))
{
$player=$_POST['player'];
$password=$_POST['password'];
$player=strip_tags($player);
$password=strip_tags($password);
$password=md5($password);
$query = "select name,password from players where name='$player' and '$password'";
$result = mysql_query($query) or die("Could not query players");
$result2 = mysql_fetch_array($result);
if ($result2)
{
$_SESSION['player']=$player;
echo "Login Berhasil!<br>";
echo " <A href='parse1.php'>Lanjutkan<a/>";
exit;
}
else
{
echo "<big>Username, Captcha atau Password Salah<A href='login.php'>Try Again</a></big>";
}
}
?>
Code: Select all
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<?php
include_once "connect.php";
if (isset($_SESSION['player']))
{
$_SESSION['player']=$player;
}
else
{
echo "Not Logged in <br><br> <A href='login.php'>Login</a>";
exit;
}
?>
<link rel="stylesheet" href="gpack/inside.css" type="text/css" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<table width="829" height="64" border="0">
<tr>
<td width="823"> </td>
</tr>
</table>
<table width="836" height="424" border="0">
<tr>
<td width="234" height="420"><table width="200" height="420" border="0">
<tr>
<td height="75"><table width="228" border="1">
<tr>
<td width="218" height="118"><div class="Standard">
<ul>
<li class="Standard"><a href="parse1.php">Peninjauan Desa</a></li>
<li><a href="parse2.php">Pusat Desa</a></li>
<li><a href="map.php">Peta</a></li>
<li><a href="rank.php">Statistik</a></li>
<li><a href="report.php">Laporan</a></li>
<li><a href="message.php">Pesan</a></li>
<hr align="left"/>
<li><a href="plus.php">Premiums</a></li>
<li><a href="help">Help</a></li>
<li><a href="profile.php">Profile</a></li>
<li><a href="clan">Clan</a></li>
<li><a href="friend.php">NAPs</a></li>
<li><a href="logout.php">Logout</a></li>
</ul>
</div></td>
</tr>
</table></td>
</tr>
<tr>
<td height="142"> </td>
</tr>
</table></td>
<td style="border-left: 2px dotted blue; padding: 5px;" width="486"></td>
<td style="border-left: 2px dotted blue; padding: 5px;" width="102"> </td>
</tr>
</table>
<p> </p>
</body>
</html>
- hallsofvallhalla
- Site Admin
- Posts: 12026
- Joined: Wed Apr 22, 2009 11:29 pm
Re: $_SESSION Problems
your issue is in log user
should be
Code: Select all
$query = "select name,password from players where name='$player' and '$password'";
Code: Select all
$query = "select name,password from players where name='$player' and password='$password'";