Re: Functions are driving me crazy....

From: Date: Fri, 25 Jan 2008 20:18:22 +0000
Subject: Re: Functions are driving me crazy....
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-268134@lists.php.net to get a copy of this message
<?PHP /// initialize the return variable $authenticated = false; function authentication(){ if(!isset($user) || !isset($pass)) { return false; } /// <-- i would do it a bit nicer than this, but you get the idea if($user && $pass) { // Keep in mind, PASSWORD has meaning in MySQL // Do your string sanitizing here // (e.g. - $user = mysql_real_escape_string($ _POST['user']);) $loginQuery = "SELECT * FROM login WHERE user='".$user."' AND Userpass='".$pass."' LIMIT 0,1;"; $loginResult = mysql_query($loginQuery) or die("Wrong data supplied or database error" .mysql_error()); while($row1 = mysql_fetch_array($loginResult)) { $_SESSION['user'] = $row1['User']; $_SESSION['loggedin'] = "YES"; $authenticated = "true"; } } }return $authenticated; ?> -nathan

« previous php.general (#268134) next »