Hello!
I have downloaded a complete “CMS” scipt with login and so on. But now i want to add a “remember me” function with php and cookies.
I have sat hours and trying to fix this but with no results. I only get errors or no fucntions at all ?. Since im toally new to php and cookies i thought i could ask you guys for help.
I have tried to add complete remember me codes into my code but didnt succeed. So thats why i post parts of my code. If someone just could edit the codes correctly i would be more than happy! ?
So heres my codes: (Im sorry that my post will be so long)
LOGIN.php
[code]
<?php
session_start();
$l = “login”;
include”top.php”;
if($login) {
$error = 0;
$errorMessage = “”;
if($username == NULL) { $error = 1; $errorMessage .= “Username must not be blank<br>”; }
if($password == NULL) { $error = 1; $errorMessage .= “Password must not be blank<br>”; }
if($error == 1) { echo “<b>ERROR:</b><br>” . $errorMessage . “</b><br>”; } else {
connect();
$password = md5($password);
$sql = “SELECT * FROM cms_users WHERE cms_users.user_uname = ‘” . $username . “‘ AND cms_users.user_password = ‘” . $password . “‘”;
$result = mysql_query($sql);
$num = mysql_num_rows($result);
if($num == 1) {
$userID = mysql_result($result, “0”, “cms_users.user_id”);
$userUName = mysql_result($result, “0”, “cms_users.user_uname”);
$userLevel = mysql_result($result, “0”, “cms_users.user_level”);
$sql = “SELECT * FROM cms_user_themes LEFT JOIN cms_themes ON cms_user_themes.theme_id = cms_themes.theme_id WHERE cms_user_themes.user_id ='” . $userID . “‘”;
$result = mysql_query($sql);
$themePath = mysql_result($result, “0”, “cms_themes.theme_path”);
$_SESSION[‘cIn’] = ‘TRUE’;
$_SESSION[‘cUserID’] = $userID;
$_SESSION[‘cUserLevel’] = $userLevel;
$_SESSION[‘cThemePath’] = $themePath;
if(isActive() == ‘FALSE’) {
$_SESSION[‘rIn’] = ‘ACTIVATE’;
echo ‘<meta http-equiv=”Refresh” content=”0;url=activate.php”>’;
include”bottom.php”;
exit();
}
echo “Welcome ” . $userUName . ” you are now logged in.”;
echo ‘<meta http-equiv=”Refresh” content=”0;url=index.php”>’;
include”bottom.php”;
exit();
} else {
echo “<b>Login Failed: Invalid username / password combination. </b><br><br>”;
}
}
}
loginForm();
?>
<br>
<a href=’forgot_pw.php’>Forgotten your password?</a>
<?php
include”bottom.php”;
?>
More info:
FUNCTIONS.php
loginForm();=
[code]
<form method=”post” action=”login.php”>
Username: <input type=”text” name=”username” value=”<?php echo $username; ?>”> <br><br>
Password: <input type=”password” name=”password”> <br><br>
<input type=”hidden” name=”login” value=”TRUE”>
<input type=”Submit” value=”Login”><br>
TOP.php (included in login.php)
[code]
<?php
session_start();
include”functions.php”;
require”setup.php”;
?>
<link rel=”stylesheet” type=”text/css” href=”<?php echo $site; ?>styles/default.css”>
<?php
if($_SESSION[‘cThemePath’] != NULL) {
?>
<link rel=”stylesheet” type=”text/css” href=”<?php echo $site; ?>styles/<?php echo $_SESSION[‘cThemePath’]; ?>”>
<?php
}
?>
<html>
<head>
<title>TITEL</title>
</head>
<body>
ETC ETC… Only a lot of html and design.
So thats all the files thats needed (i think ? )
Im [B]REALLY
Best Regards JaGgeX