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? Quote Link to comment Share on other sites More sharing options...
lemmin Posted December 12, 2007 Share Posted December 12, 2007 What do the errors say? Quote Link to comment 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, Quote Link to comment 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 Quote Link to comment 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. Quote Link to comment 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 */ Quote Link to comment 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 Quote Link to comment 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? Quote Link to comment 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." Quote Link to comment 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. Quote Link to comment 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. Quote Link to comment 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? Quote Link to comment 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] Quote Link to comment 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. Quote Link to comment 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 Quote Link to comment 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. Quote Link to comment 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. Quote Link to comment Share on other sites More sharing options...
teng84 Posted December 13, 2007 Share Posted December 13, 2007 can we see your code for that? Quote Link to comment 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. Quote Link to comment 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 Quote Link to comment 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(); Quote Link to comment 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? Quote Link to comment 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 Quote Link to comment Share on other sites More sharing options...
Xyphon Posted December 13, 2007 Author Share Posted December 13, 2007 Thank you, all fixed. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.