OK, we don't use session_register(); in modern versions of php anymore. Additionally, you need to start the session on each page you want to protect, and use $_SESSION to register vars.
PHP Code:
<?php
$host = "server";
$username = "asasas";
$password = "tututu";
$db_name = "phpacademy";
$tbl_name = "members";
mysql_connect($host, $username, $password) or die(mysql_error("can't connect"));
mysql_select_db($db_name) or die(mysql_error());
$myusername = $_POST['myusername'];
$mypassword = $_POST['mypassword'];
$sql = "SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'";
$result = mysql_query($sql);
$count = mysql_num_rows($result);
if($count==1) {
session_start();
$_SESSION["myusername"];
$_SESSION["mypassword"];
$_SESSION[$myusername];
$_SESSION[$mypassword]; // you need to declare what sessions are storing also
$message = "Success!";
}
else {
$message = "Wrong Username or Password";
}
?>
<html>
<head>
<title>login</title>
</head>
<body>
message:
<?php echo $message; ?>
</body>
</html>
PHP Code:
<?php
session_start();
if (isset($_SESSION['myusername'])){
} else {
header("Location: login.php"); // you can chg this to the login pg uri
?>
?>
<html>
<head>
<title>Forum</title>
<!---------------------------------------------------------------->
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<link rel="stylesheet" type="text/css" href="drilldownmenu.css" />
<script type="text/javascript" src="drilldownmenu.js">
</script>
<script type="text/javascript">
var mymenu=new drilldownmenu({
menuid: 'drillmenu1',
breadcrumbid: 'drillcrumb',
persist: {enable: true, overrideselectedul: true}
})
</script>
<!---------------------------------------------------------------->
</head>
<body bgcolor="black" text='#000000' link='black' atext='#000000' vlink='black'>
<table width='500px' height='40px'>
<tr>
<td>
</td>
</tr>
</table>
<table background="images/general.JPG" align='center' width='765px' height='440px' style='border-color':black;border-style:solid;borderw-width:0px border='0'>
<tr>
<td>
<table align='left' width='200px' height='300px' style='border-color':black;border-style:solid;borderw-width:0px border='0'>
<tr>
<td>
<table>
<tr>
<td>
</td>
</tr>
</table>
<table width='150px' height='200px' align='left'>
<tr>
<td>
<!-----------------------MENU--------------------------------------->
<div id="drillmenu1" class="drillmenu">
<ul>
<li><a href="">Minas Tirith</a></li>
<li><a href="members.php">Guild members</a></li>
<li><a href="forum.php">Forum</a></li>
<li><a href="killlist.php">Kill list [Pk]</a></li>
<li><a href="#">Information</a>
<ul>
<li><a href="#">Empty...</a></li>
<li><a href="#">Empty...</a></li>
<li><a href="#">Empty...</a>
</li>
</ul>
</li>
<li><a href="#">Other guilds</a>
<ul>
<li><a href="enemies.php">Enemies</a></li>
<li><a href="allies.php">Allies</a></li>
</ul>
</li>
<li><a href="traitors.php">!!!TRAITORS!!!</a></li>
<li><a href="#">Shop</a>
<ul>
<li><a href="buy.php">Buy</a></li>
<li><a href="sell.php">Sell</a></li>
<li><a href="rps.php">RPS shop</a>
<ul>
<li><a href="https://shop.playrohan.com/ItemMall/ItemMall.html">Item mall</a></li>
<li><a href="https://shop.playrohan.com/Exchange/Exchange.html">Exchange</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="http://www.playrohan.com">Play Rohan</a></li>
<li><a href="choosen.php">Choosen RooM</a></li>
</ul>
<br style="clear: left" />
</div>
<!-------------------------MENU------------------------------------->
<br><br><br>
</td>
</tr>
</table>
</td>
</tr>
</table>
<table align='right' width='500px' height='50px' style='border-color':black;border-style:solid;borderw-width:0px border='0'>
<tr>
<td>
<p><font size="5" color='#ECE5B6' face="Old English Text MT"><b>Minas Tirith guild site</b></font></p><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
</td>
</tr>
</table>
<!-------------------------langas------------------------------------->
<table background="images/members.jpg" align='right' width='500px' height='360px' style='border-color':black;border-style:solid;borderw-width:0px border='1'>
<tr align='center'>
<td align='center'>
<p><font size="2" color='black' face="Verdana"><b>Sorry... Can't connect</b></font></p><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
</td>
</tr>
</table>
<!-------------------------langas------------------------------------->
</td>
</tr>
</table>
<table align='center' width='500px' height='120px' style='border-color':black;border-style:solid;borderw-width:0px border='0'>
<tr>
<td align='center'>
</td>
</tr>
</table>
[PHP]
Bookmarks