Jump to content

Login AND logout messed


Xyphon

Recommended Posts

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
Share on other sites

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
Share on other sites

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
Share on other sites

<?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
Share on other sites

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
Share on other sites

<?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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.