Reply to Re: login problem

Your name:

Reply:


Posted by Jerry Stuckle on 06/14/72 12:02

white lightning wrote:
> Here is my login code. As I said earlier, it works perfect in
> localhost but not in web hosting server... Perhaps it's something to
> do with something else.. Not sure if i could attach files here...
> otherwise i could have sent more codes....
>
> class User {
> function User(&$db) {
> $this->db = $db;
> }
>
> function session_defaults() {
> $_SESSION['logged'] = false;
> $_SESSION['uid'] = 0;
> $_SESSION['username'] = '';
> $_SESSION['cookie'] = 0;
> $_SESSION['remember'] = false;
> }
>
> function _checkLogin($username, $password, $remember = false) {
> $username = mysql_escape_string($username);
> $password = $password;
> $sql = "SELECT * FROM member WHERE username = '$username' AND
> password = '$password'";
> $result = mysql_query($sql) or die("Could not select");
> $return_result = mysql_fetch_assoc($result);
> if (mysql_num_rows($result)) {
> if ($this->_setSession($return_result, $remember)) {
> return $return_result['username'];
> }
> } else {
> $this->failed = true;
> $this->_logout();
> return false;
> }
> }
>
>
> function _setSession(&$values, $remember, $init = true) {
> $this->id = $values['member_id'];
> $_SESSION['uid'] = $this->id;
> $_SESSION['username'] = htmlspecialchars($values['username']);
> $_SESSION['cookie'] = $values['cookie'];
> $_SESSION['logged'] = true;
> echo "session_logged: ".$_SESSION['logged'];
> if ($remember) {
> $this->updateCookie($values['cookie'], true);
> }
> if ($init) {
> $session = session_id();
> $ip = $_SERVER['REMOTE_ADDR'];
>
> $sql = "UPDATE member SET session = '$session', ip = '$ip' WHERE
> member_id = '$this->id'";
> mysql_query($sql);
> return true;
> }
> }
>
> function _logout() {
> $query = "UPDATE member SET cookie='', session='', ip='' WHERE
> member_id='{$_SESSION['uid']}'";
> mysql_query($query) or die("Could not select");
>
> $_SESSION['logged'] = false;
> $_SESSION = array();
> session_destroy();
> return true;
> }
> }
>

OK, you show us maybe 1/2 the code you use to do it. I'm sure there is
more to it than this.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация