Xyphon Posted December 12, 2007 Share Posted December 12, 2007 This is my logout No matter what I do I get errors, and normally differant ones. <?PHP ob_start(); // if logged in if (isset($_COOKIE['UserID'])) { setcookie("UserID", "$UserID", time() - 9999999); echo "You are now logged out, go to <a href='index.php'> Home</a> to log back in.; exit; } //if logged out if (!isset($_COOKIE['UserID'])) { echo "Sorry, you are already logged out. Click <a href='index.php'>Here</a> to go back."; exit; } ob_end_flush(); ?> This is my login <?PHP ob_start(); // Connects to your Database include ('Connect.php'); $submit = $_POST['submit']; //Body Settings echo "<center><font color='#AFAFAF' face='verdana' size='1'>"; //If User Is Logged In if (isset($_COOKIE['UserID'])) { //Display Message echo "Sorry, you are already logged in. Click <a href='index.php'>Here</a> to go back."; //Exit Page exit; } //If Form Is Submitted if ($submit) { // Checks if pass/user exists $usercheck = addslashes($_POST['username']); $passcheck = md5(addslashes($_POST['password'])); $Result1 = mysql_query("SELECT * FROM users WHERE username='$usercheck' AND password='$passcheck'"); $Rows1 = mysql_fetch_array($Result1); if (mysql_num_rows($Result1) == 0) { echo "Invalid Username/password."; exit; } $UserID = $Rows1['ID']; setcookie("UserID", "$UserID", time() + 9999999); echo "You have successfully logged in. <a href='index.php'>Continue</a>"; } //If Form Isn't Submitted else { echo " <form method='POST'> <input type='hidden' name='submit' value='1'> <b>Username</b> <input type=\"text\" name=\"username\" maxlength=\"30\"> <br /> <b>Password</b> <input type=\"password\" name=\"password\" maxlength=\"25\"> <br /> <input type='submit' value='Sign In' onclick=\"this.disabled='true'; this.value='Please Wait...'; this.form.submit();\"> </form>"; } ob_end_flush(); ?> It works in mozzila, but not internet.. Help? Link to comment https://forums.phpfreaks.com/topic/81408-login-and-logout-messed/ Share on other sites More sharing options...
lemmin Posted December 12, 2007 Share Posted December 12, 2007 What do the errors say? Link to comment https://forums.phpfreaks.com/topic/81408-login-and-logout-messed/#findComment-413166 Share on other sites More sharing options...
Xyphon Posted December 12, 2007 Author Share Posted December 12, 2007 Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/www/ptcrpg.awardspace.com/logout.php on line 10 I dont know why its saying that, and the other is $ sign on last line, which is something to do with the brackets, which I see nothing wrong. On login, it just doesnt load for IE.. Like, when I click submit it says please wait but ntohing happens, Link to comment https://forums.phpfreaks.com/topic/81408-login-and-logout-messed/#findComment-413171 Share on other sites More sharing options...
Xyphon Posted December 12, 2007 Author Share Posted December 12, 2007 I fixed up login a bit <?PHP ob_start(); $usercheck = addslashes($_POST['username']); $passcheck = md5(addslashes($_POST['password'])); $Result1 = mysql_query("SELECT * FROM users WHERE username='$usercheck' AND password='$passcheck'"); $Rows1 = mysql_fetch_array($Result1); $UserID = $Rows1['ID']; // if logged out if (isset($_COOKIE['UserID'])) { setcookie("UserID", "$UserID", time() - 9999999); echo "You are now logged out, go to <a href='index.php'> Home</a> to log back in.; exit; } if (!isset($_COOKIE['UserID'])) { echo "Sorry, you are already logged out. Click <a href='index.php'>Here</a> to go back."; exit; } ob_end_flush(); ?> But it has Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/www/ptcrpg.awardspace.com/logout.php on line 17 Link to comment https://forums.phpfreaks.com/topic/81408-login-and-logout-messed/#findComment-413183 Share on other sites More sharing options...
lemmin Posted December 12, 2007 Share Posted December 12, 2007 You didn't end the quotes on your "You are now logged out..." echo statement. Link to comment https://forums.phpfreaks.com/topic/81408-login-and-logout-messed/#findComment-413186 Share on other sites More sharing options...
efm Posted December 12, 2007 Share Posted December 12, 2007 Try using different comments... instead of //If Form Isn't Submitted use /* If Form Isn't Submitted */ Link to comment https://forums.phpfreaks.com/topic/81408-login-and-logout-messed/#findComment-413188 Share on other sites More sharing options...
Xyphon Posted December 12, 2007 Author Share Posted December 12, 2007 <?PHP <?PHP include('Connect.php') ob_start(); $usercheck = addslashes($_POST['username']); $passcheck = md5(addslashes($_POST['password'])); $Result1 = mysql_query("SELECT * FROM users WHERE username='$usercheck' AND password='$passcheck'"); $Rows1 = mysql_fetch_array($Result1); $UserID = $Rows1['ID']; /* if logged in */ if (isset($_COOKIE['UserID'])) { setcookie("UserID", "$UserID", time() - 9999999); echo "You are now logged out, go to <a href='index.php'> Home</a> to log back in."; exit; } /* if logged out */ if (!isset($_COOKIE['UserID'])) { echo "Sorry, you are already logged out. Click <a href='index.php'>Here</a> to go back."; exit; } ob_end_flush(); ?> I got the error Parse error: parse error, unexpected T_STRING in /home/www/ptcrpg.awardspace.com/logout.php on line 3 Link to comment https://forums.phpfreaks.com/topic/81408-login-and-logout-messed/#findComment-413191 Share on other sites More sharing options...
Xyphon Posted December 12, 2007 Author Share Posted December 12, 2007 Never mind, fixed myself. Now does anyone have tips for Mozzila and internet tihng for login? Link to comment https://forums.phpfreaks.com/topic/81408-login-and-logout-messed/#findComment-413193 Share on other sites More sharing options...
lemmin Posted December 12, 2007 Share Posted December 12, 2007 If you have "<?php" there twice, remove one of them. I assume that got added when you were posting, though. Otherwise, include is not a function. You should be using it like: include "Connect.php"; It works the way you have it because php is smart, but it is better to not make it think so much. The main problem is that you need a semicolon at the end of that line. I'm not sure what you mean by "Mozzila and internet thing for login." Link to comment https://forums.phpfreaks.com/topic/81408-login-and-logout-messed/#findComment-413197 Share on other sites More sharing options...
Xyphon Posted December 12, 2007 Author Share Posted December 12, 2007 Well. For my login and such, Internet explorer will click submit, but it wont load. While Mozzila firefox will. Link to comment https://forums.phpfreaks.com/topic/81408-login-and-logout-messed/#findComment-413199 Share on other sites More sharing options...
lemmin Posted December 12, 2007 Share Posted December 12, 2007 My guess is that you have javascript disabled on your internet explorer. See if that is the problem and turn it on if so. Link to comment https://forums.phpfreaks.com/topic/81408-login-and-logout-messed/#findComment-413202 Share on other sites More sharing options...
Xyphon Posted December 12, 2007 Author Share Posted December 12, 2007 I ahve java applets enabled, how do I check javascript? Link to comment https://forums.phpfreaks.com/topic/81408-login-and-logout-messed/#findComment-413204 Share on other sites More sharing options...
lemmin Posted December 12, 2007 Share Posted December 12, 2007 Tools > Internet Options > Security > Custom Level... > Scripting > Active Scripting > [Enabled] Link to comment https://forums.phpfreaks.com/topic/81408-login-and-logout-messed/#findComment-413212 Share on other sites More sharing options...
Xyphon Posted December 12, 2007 Author Share Posted December 12, 2007 IT is enabled, still doesnt work. I click submit, it says please wait, it deosnt load. Link to comment https://forums.phpfreaks.com/topic/81408-login-and-logout-messed/#findComment-413213 Share on other sites More sharing options...
teng84 Posted December 12, 2007 Share Posted December 12, 2007 <script> document.write(new java.lang.String("JS IS WORKING")); </script> will out put JS IS WORKING if JS is enable Link to comment https://forums.phpfreaks.com/topic/81408-login-and-logout-messed/#findComment-413218 Share on other sites More sharing options...
lemmin Posted December 12, 2007 Share Posted December 12, 2007 Oh, it is because the form is not a child element of the input tag. I'm really not sure why that works in firefox. Change: <form method='POST'> to: <form id="frm" method='POST'> AND change: this.form.submit(); to: frm.submit(); That should work. Link to comment https://forums.phpfreaks.com/topic/81408-login-and-logout-messed/#findComment-413262 Share on other sites More sharing options...
Xyphon Posted December 13, 2007 Author Share Posted December 13, 2007 Well, I did that, and it got me to change "frm" to 'frm', when i did that, I went to submit, and it says error on page, and doesnt submit. Link to comment https://forums.phpfreaks.com/topic/81408-login-and-logout-messed/#findComment-413397 Share on other sites More sharing options...
teng84 Posted December 13, 2007 Share Posted December 13, 2007 can we see your code for that? Link to comment https://forums.phpfreaks.com/topic/81408-login-and-logout-messed/#findComment-413406 Share on other sites More sharing options...
revraz Posted December 13, 2007 Share Posted December 13, 2007 I must be blind, I dont see any Java in your code you've posted. Link to comment https://forums.phpfreaks.com/topic/81408-login-and-logout-messed/#findComment-413409 Share on other sites More sharing options...
Xyphon Posted December 13, 2007 Author Share Posted December 13, 2007 <?PHP ob_start(); // Connects to your Database include ('Connect.php'); $submit = $_POST['submit']; //Body Settings echo "<center><font color='#AFAFAF' face='verdana' size='1'>"; //If User Is Logged In if (isset($_COOKIE['UserID'])) { //Display Message echo "Sorry, you are already logged in. Click <a href='index.php'>Here</a> to go back."; //Exit Page exit; } //If Form Is Submitted if ($submit) { // Checks if pass/user exists $usercheck = addslashes($_POST['username']); $passcheck = md5(addslashes($_POST['password'])); $Result1 = mysql_query("SELECT * FROM users WHERE username='$usercheck' AND password='$passcheck'"); $Rows1 = mysql_fetch_array($Result1); if (mysql_num_rows($Result1) == 0) { echo "Invalid Username/password."; exit; } $UserID = $Rows1['ID']; setcookie("UserID", "$UserID", time() + 9999999); echo "You have successfully logged in. <a href='index.php'>Continue</a>"; } //If Form Isn't Submitted else { echo " <form id='frm' method='POST'> <input type='hidden' name='submit' value='1'> <b>Username</b> <input type=\"text\" name=\"username\" maxlength=\"30\"> <br /> <b>Password</b> <input type=\"password\" name=\"password\" maxlength=\"25\"> <br /> <input type='submit' value='Sign In' onclick=\"this.disabled='true'; this.value='Please Wait...'; frm.submit();\"> </form>"; } ob_end_flush(); ?> And Huh? You mean javascript? Im not very experienced O.O Link to comment https://forums.phpfreaks.com/topic/81408-login-and-logout-messed/#findComment-413411 Share on other sites More sharing options...
revraz Posted December 13, 2007 Share Posted December 13, 2007 Why not just change the one line to HTML? <input type='submit' value='Sign In' onclick=\"this.disabled='true'; this.value='Please Wait...'; frm.submit(); Link to comment https://forums.phpfreaks.com/topic/81408-login-and-logout-messed/#findComment-413417 Share on other sites More sharing options...
Xyphon Posted December 13, 2007 Author Share Posted December 13, 2007 Why not just change the one line to HTML? <input type='submit' value='Sign In' onclick=\"this.disabled='true'; this.value='Please Wait...'; frm.submit(); So, how do I turn it into HTML? Link to comment https://forums.phpfreaks.com/topic/81408-login-and-logout-messed/#findComment-413419 Share on other sites More sharing options...
revraz Posted December 13, 2007 Share Posted December 13, 2007 http://www.w3.org/TR/html4/interact/forms.html Link to comment https://forums.phpfreaks.com/topic/81408-login-and-logout-messed/#findComment-413434 Share on other sites More sharing options...
Xyphon Posted December 13, 2007 Author Share Posted December 13, 2007 Thank you, all fixed. Link to comment https://forums.phpfreaks.com/topic/81408-login-and-logout-messed/#findComment-413441 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.