Jump to content

entity azirius

Members
  • Posts

    6
  • Joined

  • Last visited

entity azirius's Achievements

Newbie

Newbie (1/7)

0

Reputation

  1. Well it doesn't seem to be the cookies, it just seems to be how my MySQL and other PHP is set up, though I'm not too sure what to do to make it right... strange.Thanks for verifying the Cookies though
  2. Well, because I've experianced the annoyance in that, sometimes I use the wrong shortcut on the Keyboard or accidently close the window, but with a cookie (that is only one hour long by the way) will keep you logged on until you logout! Well I've modified my files even more but still no difference, I'll post what I have now!LoginV.php <?phpif($submit == "") {echo("<div class=\"warning\">Fatal Error Script Ended</div>");}elseif($submit == "submitted") {require_once("config.php");$username = $_POST['user']; //pulls the username from the form$password = $_POST['password']; //pulls the pass from the form$password2 = md5($password); //makes our password an md5//selects info from our table if the row has the same user and pass that our form does$login = mysql_query("SELECT * FROM users WHERE `user` = '$username' AND `password` = '$password'");if(!mysql_num_rows($login)) //if the username and pass are wrong{echo("Password or username is wrong, try again!\n");echo("<meta http-equiv=\"refresh\" content=\"0; URL=http://eagame.entitys-arena.co.uk/V2LC/index.php?eagame=login\">"); //redirects to our login page}else {//sets our user cookie$rk = $row['rank'];$un = $row['user'];$navID = $row['id'];setcookie("user", $username, time()+3600);//sets our pass cookiesetcookie("pass", $password2, time()+3600);//instead of yourpage.php it would be your protected pageecho("Thank you $username, you are being redirected to the news center!");echo("<meta http-equiv=\"refresh\" content=\"5; URL=http://eagame.entitys-arena.co.uk/V2LC/index.php?eagame=news&action=users&uid=$navID&un=$un&rank=$rk\">"); //redirects to our login page }}?> Navigtaion.php <table width="100%"><tr><td>Navigation</td></tr><tr><td class="navigation"><ul><li><a href="/V2LC/index.php">Index</a></li><li><a href="index.php?eagame=info">Information</a></li><li><a href="index.php?eagame=about">About</a></li></ul><?php// Check if cookie exists...if(isset($_COOKIE['user']) && isset($_COOKIE['pass'])) {require_once("config.php");echo("<ul>");$navID = $_GET['$navID'];$navRank = $_GET['$rk'];$username = $_GET['$un'];$result = mysql_query("SELECT * FROM users");echo mysql_error($con);while($row = mysql_fetch_array($result)) {$navID = $row['id'];$navRank = $row['rank'];$username = $row['user'];echo("Welcome $username\n<br />\nRank: $navRank\n");if($navRank == "Administrator") {echo("<li><a href=\"index.php?eagame=news&action=userCP&uid=$navID\">User Control Panel</a></li>\n");echo("<li><a href=\"index.php?eagame=news&action=register\">Register A User</a></li>\n");echo("<li><a href=\"index.php?eagame=news&action=users\">Views Users</a></li>\n");echo("<li><a href=\"index.php?eagame=news&action=addartcile\">Add Article</a></li>\n");echo("<li><a href=\"index.php?eagame=news&action=logout\">Log Out</a></li>\n");}elseif($navRank == "Co-Administrator") {echo("<li><a href=\"index.php?eagame=news&action=userCP&id=$id\">User Control Panel</a></li>\n");echo("<li><a href=\"index.php?eagame=news&action=register\">Register A User</a></li>\n");echo("<li><a href=\"index.php?eagame=news&action=users\">Views Users</a></li>\n");echo("<li><a href=\"index.php?eagame=news&action=addartcile\">Add Article</a></li>\n");echo("<li><a href=\"index.php?eagame=news&action=logout\">Log Out</a></li>\n");}elseif($navRank == "News Editor") {echo("<li><a href=\"index.php?eagame=news&action=userCP&id=$id\">User Control Panel</a></li>\n");echo("<li><a href=\"index.php?eagame=news&action=addartcile\">Add Article</a></li>\n");echo("<li><a href=\"index.php?eagame=news&action=logout\">Log Out</a></li>\n");}elseif($navRank == "News Reporter") {echo("<li><a href=\"index.php?eagame=news&action=userCP&id=$id\">User Control Panel</a></li>\n");echo("<li><a href=\"index.php?eagame=news&action=addartcile\">Add Article</a></li>\n");echo("<li><a href=\"index.php?eagame=news&action=logout\">Log Out</a></li>\n");}echo("</ul>");}}elseif(empty($_COOKIE['user']) && empty($_COOKIE['pass'])) {echo("<ul>");echo("<li><a href=\"index.php?eagame=login\">Staff Login</a></li>\n");echo("</ul>");}?></td></tr></table> Logout.php <?php$username = "";$password2 = "";//sets our user cookiesetcookie("user", $username);//sets our pass cookiesetcookie("pass", $password2);echo("$username; You have been logged out, redirecting to home page!");echo("<meta http-equiv=\"refresh\" content=\"5; URL=http://eagame.entitys-arena.co.uk/V2LC/index.php\">"); //redirects to our login page?> I am really stuck with this, I don't usually ask for help as I like to solve things my way, but this time I need help.
  3. Well I've managed to fix one part and replaced part of the code as well, so I've edited part of the question out.PS: sorry for the double post Just wanted too update on things!
  4. Hi, me again! :)Just having quite a few problems with my login script, for some reason when I log out and delete the cookies with the logout page everytime I log back in, I log in again with EXACTLY the same user. Weird huh? I know its probably something I've done, but it's damned annoying!Here I'll post the code of all my files.Login Form (login.php): <form action="index.php?eagame=loginV" method="post" name="loginform" id="loginform"><input type="hidden" value="submitted" name="submit" /><table><tr><td colspan="2">Login</td></tr><tr><td>Username</td><td><input type="text" name="user" /></td></tr><tr><td>Password</td><td><input type="password" name="password" /></td></tr><tr><td colspan="2"><input type="submit" value="Login" /></td></tr></table></form> Login Verification (loginV.php): <?phpif($submit == "") {echo("<div class=\"warning\">Fatal Error Script Ended</div>");exit(END);}elseif($submit == "submitted") {require_once("config.php");$username = $_POST['user']; //pulls the username from the form$password = $_POST['password']; //pulls the pass from the form$password2 = md5($password); //makes our password an md5//selects info from our table if the row has the same user and pass that our form does$login = mysql_query("SELECT * FROM `users` WHERE `user` = '$username' AND `password` = '$password'"); if(!mysql_num_rows($login)) //if the username and pass are wrong{echo("Password or username is wrong, try again!\n");echo("<meta http-equiv=\"refresh\" content=\"0; URL=http://eagame.entitys-arena.co.uk/V2LC/index.php?eagame=login\">"); //redirects to our login pagedie(); //stops the page from going any further}else{//sets our user cookiesetcookie("user", $username, time()+3600);//sets our pass cookiesetcookie("pass", $password2, time()+3600);//instead of yourpage.php it would be your protected pageecho("Thank you $username, you are being redirected to the news center!");echo("<meta http-equiv=\"refresh\" content=\"0; URL=http://eagame.entitys-arena.co.uk/V2LC/index.php?eagame=news\">"); //redirects to our login page} }?> Log Out code (logout.php): <?php$username = "";$password2 = "";//sets our user cookiesetcookie("user", $username);//sets our pass cookiesetcookie("pass", $password2);echo("$username; You have been logged out, redirecting to home page!");echo("<meta http-equiv=\"refresh\" content=\"5; URL=http://eagame.entitys-arena.co.uk/V2LC/index.php\">"); //redirects to our login page?> and finally the Navigation code (navigation.php): <table width="100%"><tr><td>Navigation</td></tr><tr><td class="navigation"><ul><li><a href="/V2LC/index.php">Index</a></li><li><a href="index.php?eagame=info">Information</a></li><li><a href="index.php?eagame=about">About</a></li></ul><?php// Check if cookie exists...if(isset($_COOKIE['user']) && isset($_COOKIE['pass'])) {require_once("config.php");echo("<ul>");$result = mysql_query("SELECT * FROM users");echo mysql_error($con);$row = mysql_fetch_array($result);$navRank = $row['rank'];$username = $row['user'];echo("Welcome $username\n<br />Rank: $navRank\n");if($navRank == "Administrator"){echo("<li><a href=\"index.php?eagame=news&action=userCP\">User Control Panel</a></li>\n");echo("<li><a href=\"index.php?eagame=news&action=register\">Register A User</a></li>\n");echo("<li><a href=\"index.php?eagame=news&action=users\">Views Users</a></li>\n");echo("<li><a href=\"index.php?eagame=news&action=addartcile\">Add Article</a></li>\n");echo("<li><a href=\"index.php?eagame=news&action=logout\">Log Out</a></li>\n");}elseif($navRank == "Co-Administrator") {echo("<li><a href=\"index.php?eagame=news&action=userCP\">User Control Panel</a></li>\n");echo("<li><a href=\"index.php?eagame=news&action=register\">Register A User</a></li>\n");echo("<li><a href=\"index.php?eagame=news&action=users\">Views Users</a></li>\n");echo("<li><a href=\"index.php?eagame=news&action=addartcile\">Add Article</a></li>\n");echo("<li><a href=\"index.php?eagame=news&action=logout\">Log Out</a></li>\n");}elseif($navRank == "News Editor") {echo("<li><a href=\"index.php?eagame=news&action=userCP\">User Control Panel</a></li>\n");echo("<li><a href=\"index.php?eagame=news&action=addartcile\">Add Article</a></li>\n");echo("<li><a href=\"index.php?eagame=news&action=logout\">Log Out</a></li>\n");}elseif($navRank == "News Reporter") {echo("<li><a href=\"index.php?eagame=news&action=userCP\">User Control Panel</a></li>\n");echo("<li><a href=\"index.php?eagame=news&action=addartcile\">Add Article</a></li>\n");echo("<li><a href=\"index.php?eagame=news&action=logout\">Log Out</a></li>\n");}echo("</ul>");}elseif(empty($_COOKIE['user']) && empty($_COOKIE['pass'])) {echo("<ul>");echo("<li><a href=\"index.php?eagame=login\">Staff Login</a></li>\n");echo("</ul>");}?></td></tr></table> Any help on this would be appriciated.Regards, entity azirius.
  5. You asssume correct, I just didn't wanna give away my conection details. Well it seems to have sorted itself out now. Thank you very much for your help, you gave me a bit of extra information as well! Thank you!
  6. Today I am taking my first steps into using MySQL and I have had a lot of problems with it.Userlist.php <?php$con = mysql_connect("localhost","VALID USER","VALID PASS");if (!$con) { die('Could not connect: ' . mysql_error());}mysql_select_db("VALID DB", $con);$result = mysql_query("SELECT * FROM user");while($row = mysql_fetch_array($result)) { echo $row['username']; echo "<br />"; echo $row['email']; echo "<br />"; echo $row['registration_date']; echo "<br />"; echo $row['user_id']; echo "<br />";}?> I've finally got to my last piece of coding, but an error keeps being proccessed: Now apparently what I've scrippted is wrong, but according to this My code looks correct to me. If someone could help me with my problems then I'd be majorly greatful.Regards, entity azirius.
×
×
  • Create New...