Jump to content

How would I go about doing this?


Xyphon

Recommended Posts

<?PHP
// Connects to your Database
include ('Connect.php');
include('top.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'>
</form>";
}
include('bottom.php');
?>

you are using setcookie,

 

 

MEANING $_SESSION['login'] or whatever Should be $_COOKIE['UserID']

 

try

 

<?php
include('Connect.php');
include('top.php');
$submit = $_POST['submit'];
$username = $_COOKIE['UserID'];
$comment = $_POST['comment'];
if ($submit) {

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.