Roon
Member
- Mar 31, 2013
- 60
- 9
Okay, so my code in the whole page is...
And my error is
Notice: Undefined variable: _SESSION in D:\Xampp\htdocs\ForumZer\inc\inc.main.php on line 59
However, when I do "session_start();" it says
Notice: Undefined index: Username in D:\Xampp\htdocs\ForumZer\inc\inc.main.php on line 60
Notice: A session had already been started - ignoring session_start() in D:\Xampp\htdocs\ForumZer\inc\inc.main.php on line 25
I am completely oblivious as to why this is happening and I would appreciate some help. Thanks!
I
PHP:
<?php
class forum {
public function connect() {
$con = mysql_connect('');
mysql_select_db('forum', $con);
}
public function login() {
$Username = $_POST['Username'];
$Password = $_POST['Password'];
$fetch_Username = mysql_query("SELECT * FROM `users` WHERE `Username` = '$Username'");
$fetch_Password = mysql_query("SELECT * FROM `users` WHERE `Password` = '$Password'");
$row_U = mysql_num_rows($fetch_Username);
$row_P = mysql_num_rows($fetch_Password);
if($row_U && $row_P == 1){
session_start();
$_SESSION['Username'] = $Username;
header('Location: ../index.php');
}
else {
header('Location: ../loginfailed.php');
}
}
public function loginouty() {
session_start();
if(!isset($_SESSION['Username'])) {
echo "<form style=\"display: inline-block; position: absolute; right: -1050px;\" action=\"inc/inc.main.php\" method=\"POST\" name=\"Form-Login\">
<input style=\"margin-top:5px;\" type=\"text\" id=\"loginname\" class=\"input-small\" placeholder=\"Username\" name=\"Username\">
<input style=\"margin-top:5px;\" type=\"password\" id=\"loginpass\" class=\"input-small\" placeholder=\"Password\" name=\"Password\">
<input type=\"button\" id=\"loginsub\" class=\"btn btn-inverse\" value=\"Login\" name=\"Login-Button\">
<input type=\"submit\" id=\"realloginsub\" class=\"btn btn-inverse\" value=\"Login\" name=\"Login-Form-Button\">
</form>";
}
else {
$Username = $_SESSION['Username'];
echo "<form action=\"logout.php\" style=\"display: inline-block; position: absolute; right: -1050px;\">
<input type=\"submit\" class=\"btn btn-danger\" value=\"Logout\">
</form>";
echo " <div style=\"margin-top: 3.5px; display: inline-block; position: absolute; right: -965px;\" class=\"btn-group\">
<button class=\"btn\">$Username</button>
<button class=\"btn dropdown-toggle\" data-toggle=\"dropdown\">
<span class=\"caret\"></span>
</button>
<ul class=\"dropdown-menu\">
<li class=\"divider\"></li>
<li><a style=\"text-align: center;\" href=\"account.php\">My Account</a></li>
<li><a style=\"text-align: center;\" href=\"settings.php\">Settings</a></li>
<li class=\"divider\"></li>
<li><a style=\"text-align: center;\" href=\"#\">New Status</a></li>
<li><a style=\"text-align: center;\" href=\"#\">New Avatar</a></li>
<li class=\"divider\"></li>
</ul>
</div>";
}
}
}
class amlinks {
public function amlinker() {
$Username = $_SESSION['Username'];
$aretheyMOD = mysql_query("SELECT * FROM `users` WHERE `Username` = '$Username' AND `isMod` = '1'");
$aretheyADMIN = mysql_query("SELECT * FROM `users` WHERE `Username` = '$Username' AND `isAdmin` = '1'");
$rows_MOD = mysql_num_rows($aretheyMOD);
$rows_ADMIN = mysql_num_rows($aretheyADMIN);
if($rows_MOD == 1) {
echo "<form style=\"display: inline-block; position: absolute; right: -800px; margin-top: 6px;\" action=\"mod/modcp.php\"><input class=\"btn-small btn-primary\" type=\"submit\" value=\"MCP\"></input></form>";
}
if($rows_ADMIN == 1) {
echo "<form style=\"display: inline-block; position: absolute; right: -870px; margin-top: 6px;\" action=\"admin/admincp.php\"><input class=\"btn-small btn-danger\" type=\"submit\" value=\"ACP\"></input></form>";
}
}
}
$forum = new forum;
$forum->connect();
$ams = new amlinks;
?>
<?php
if(isset($_POST['Login-Form-Button'])) {
$forum->login();
}
?>
And my error is
Notice: Undefined variable: _SESSION in D:\Xampp\htdocs\ForumZer\inc\inc.main.php on line 59
However, when I do "session_start();" it says
Notice: Undefined index: Username in D:\Xampp\htdocs\ForumZer\inc\inc.main.php on line 60
Notice: A session had already been started - ignoring session_start() in D:\Xampp\htdocs\ForumZer\inc\inc.main.php on line 25
I am completely oblivious as to why this is happening and I would appreciate some help. Thanks!
I