Temos pavadinimas: WordPress, Shopify ir PHPFusion programuotojų bendruomenė :: Sessions hoste neveikia

Parašė sidicer· 2012 Sau. 25 17:01:02
#12

login.php:

<?php
	session_start();
	// <span style="border-bottom: 1px dotted black;">mysql</span> connect
	include("mysqlconnect.php");
?>
 
<?php
	if(isset($_SESSION['prisijunges'])) { header("Location: index.php?page=logged"); die("Tu jau esi prisijungęs. Eik į: index.php?page=logged"); }
?>
 
<?php
 
	if(isset($_POST['submit']))
	{
		$username = addslashes($_POST['username']);
		$password = addslashes($_POST['password']);
 
		if (!$username || !$password) { echo "Jūs neįvedėte duomenų!"; }
		else
		{
			$get = mysql_query("SELECT * FROM players WHERE Name='$username'");
			if (mysql_num_rows($get) < 1) { echo "Vartotojo tokiu vardu nėra."; }
			else
			{
				while ($row = mysql_fetch_assoc($get))
				{
					$id     = $row['id'];
					$name   = $row['Name']; // Vardas
					$pass   = $row['Password']; // Slaptažodis
					$alevel = $row['level']; // Admin Lygis
					$money  = $row['money']; // Pinigai
					$score  = $row['score']; // Taškai
					$kills  = $row['kills']; // Nužudimai
					$deaths = $row['deaths']; // Mirtys
					$elevel = $row['eLevel']; // Lygis
					$exp    = $row['Exp']; // Patirtis
					$rban   = $row['RBAN']; // Kiek kartu buvo išKickintas
					$laston = $row['LastOn']; // Paskutinį kart matytas
				}
 
				if ($password != $pass) { echo "Neteisingas slaptažodis"; }
				else
				{
					$_SESSION['prisijunges']=$id;
					header("Location: index.php?page=logged");
				}
			}
		}
	}
 
?>
 
	<form method="post">
		<table>
			<tr>
				<td>Vardas serveryje: </td>
				<td><input type="text" name="username" /></td>
			</tr>
			<tr>
				<td>Slaptažodis serveryje: </td>
				<td><input type="password" name="password" /></td>
			</tr>
			<tr>
				<td></td>
				<td><input type="submit" name="submit" value="Prisijungti" /></td>
			</tr>
		</table>
	</form>


mysqlconnect.php:

<?php
 
	// <span style="border-bottom: 1px dotted black;">mysql</span> connect
	$con = mysql_connect('s1.justhost.lt','8007','**') or die("Negaliu prisijungti prie <span style="border-bottom: 1px dotted black;">MySQL</span>!");
	// <span style="border-bottom: 1px dotted black;">mysql</span> database
	mysql_select_db('8007_server',$con) or die("Negaliu rasti <span style="border-bottom: 1px dotted black;">MySQL</span> duombazės!");
 
?>


logged.php:

<?php
	session_start();
	// <span style="border-bottom: 1px dotted black;">mysql</span> connect
	include("mysqlconnect.php");
?>
<?php
	if(!isset($_SESSION['prisijunges'])) { header("Location: index.php?page=login"); die("Tu nesi prisijungęs. Eik į: index.php?page=login"); }
?>
<?php
$id = $_SESSION['prisijunges'];
$get = mysql_query("SELECT * FROM players WHERE id='$id'");
while ($row = mysql_fetch_assoc($get))
{
	$id     = $row['id'];
	$name   = $row['Name']; // Vardas
	$pass   = $row['Password']; // Slaptažodis
	$alevel = $row['level']; // Admin Lygis
	$money  = $row['money']; // Pinigai
	$score  = $row['score']; // Taškai
	$kills  = $row['kills']; // Nužudimai
	$deaths = $row['deaths']; // Mirtys
	$exp    = $row['Exp']; // Patirtis
	$elevel = $row['eLevel']; // Lygis
	$rban   = $row['RBAN']; // Kiek kartu buvo išKickintas
	$laston = $row['LastOn']; // Paskutinį kart matytas
}
?>
<style>
#logged td { padding: 5px; }
</style>
<table id="logged">
	<tr>
		<td>Vardas: </td>
		<td><b><?php echo $name; ?></b></td>
	</tr>
	<?php
	if($alevel>0)
	{
	?>
	<tr>
		<td>Admin Lygis: </td>
		<td><b><?php echo $alevel; ?></b></td>
	</tr>
	<?php
	}
	?>
	<tr>
		<td>Pinigai: </td>
		<td><b><?php echo $money; ?></b></td>
	</tr>
	<tr>
		<td>Taškai: </td>
		<td><b><?php echo $score; ?></b></td>
	</tr>
	<tr>
		<td>Nužudymai: </td>
		<td><b><?php echo $kills; ?></b></td>
	</tr>
	<tr>
		<td>Mirtys: </td>
		<td><b><?php echo $deaths; ?></b></td>
	</tr>
	<tr>
		<td>Patirtis: </td>
		<td><b><?php echo $exp; ?></b></td>
	</tr>
	<tr>
		<td>Lygis: </td>
		<td><b><?php echo $elevel; ?></b></td>
	</tr>
	<tr>
		<td>Kickintas: </td>
		<td><b><?php if($rban==0){echo "<span style='color:lime'>$rban</span>";}else{echo "<span style='color:red'>$rban</span>";} ?></b></td>
	</tr>
	<tr>
		<td>Pask. Logas: </td>
		<td><b><?php echo $laston; ?></b></td>
	</tr>
</table>