/    Sign up×
Community /Pin to ProfileBookmark

Remember me function

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”;

?>
[/code]

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>
[/code]

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.
[/code]

So thats all the files thats needed (i think ? )

Im [B]REALLY[/B] thankful for answers! ?

Best Regards JaGgeX

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@so_is_thisOct 22.2006 — I don't see any code for cookies. Did you post any?
Copy linkTweet thisAlerts:
@jaggexauthorOct 22.2006 — No I didnt post any code for cookies. I want to inplent the "cookie-code" into my code. Thats what i want to know, where to put what.

But i can post some cookie tutorials:

[B]- http://www.brainbell.com/tutorials/php/TOC_Remembering_Users_(Cookies_And_Sessions).html[/B]

[B]- http://www.phpbuddy.com/article.php?id=12[/B]

Is there anyone who could help me inplent that codes into my code so it remembers username and password?

Thankful for answers! ?
×

Success!

Help @jaggex spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.13,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...