Jump to content

need help with login proble phpmyadmin


daruga

Recommended Posts


<?php
function user_exists ($username) {
$username = sanitize($username);
return(mysql_result(mysql_query("SELECT COUNT('user_id') FROM 'users' WHERE 'username' = '$username'"), 0) == 1) ? true : false;
}

function user_active($username){
$username = sanitize($username);
return (mysql_result(mysql_query("SELECT COUNT('user_id') FROM 'users' WHERE 'username' = '$username' AND 'active' = 1"), 0) == 1) ? true : false;
}

function user_id_from_username($username) {
$username = sanitize($username);
return mysql_result(mysql_query("SELECT 'user_id' FROM 'users' WHERE 'username' ='$username'"), 0, 'user_id');
}

function login ($username, $password) {
$user_id = user_id_from_username($username);

$username = sanitize($username);
$password = md5($password);

return (mysql_result(mysql_query("SELECT COUNT ('user_id') From 'users' WHERE 'username' = '$username' AND 'password' = '$password'"), 0) ==1) ? $user_id : false;
}

?>

 

Edited by daruga
Link to comment
Share on other sites

 

 

SELECT COUNT ('user_id') From 'users' WHERE 'username' = '$username' AND 'password' = '$password'"

All words highlighted in red/purple are field/table names. These should not have quotes wrapped round them. only field values should be wrapped in quotes.

Edited by Ch0cu3r
Link to comment
Share on other sites

<aside id="Just_A_Random_ID">
        
<?php 
if (logged_in)() === true {
	echo 'Logged in';
} else {




include "includes/widgets/login.php";

}
?>
		
 </aside>

 

 Parse error: syntax error, unexpected ')' in C:\wamp\www\mkjb\includes\aside.php on line 4

Call Stack # Time Memory Function Location 1 0.0004 140960 {main}( ) ..\register.php:0 2 0.0008 142384 include( 'C:\wamp\www\mkjb\includes\overall\overallheader.php' )

..\register.php:1

 

 

 

how to fix this error

Link to comment
Share on other sites

I guess logged_in is a function? Then you have the parenthesis's (these are the ( and ) characters ) in the wrong place
 
remove the red character (wrong place) and add the blue character (correct place)
 

if (logged_in)() === true){
         wrong ^             ^ right

Edited by Ch0cu3r
Link to comment
Share on other sites

<?php
function logged_in() {
    return (isset($_SESSION['user_id'])) ? true : false;

	 
	}

function user_exists ($username) {
	$username = sanitize($username);
	return(mysql_result(mysql_query ("SELECT COUNT(user_id) FROM users WHERE username = '$username'"), 0) == 1) ? true : false;
} 

function user_active($username){
     $username = sanitize($username);
     return (mysql_result(mysql_query("SELECT COUNT(user_id) FROM users WHERE username = '$username' AND active = 1"), 0) == 1) ? true : false;   
}

function user_id_from_username($username) {
	$username = sanitize($username);
	return mysql_result(mysql_query("SELECT user_id FROM users WHERE username ='$username'"), 0, 'user_id');
}

function login ($username, $password) {
	$user_id = user_id_from_username($username);
	
		$username = sanitize($username);
		$password = md5($password);
		
		return (mysql_result(mysql_query("SELECT COUNT(user_id) From users WHERE username = '$username' AND password = '$password'"), 0) ==1) ? $user_id : false;
}
?>
<aside>
        
<?php 
if (logged_in() === true) {
include 'includes/widgets/loggedin.php';
} else {

include "includes/widgets/login.php";
}

?>
		
 </aside>
 Fatal error: Call to undefined function logged_in() in C:\wamp\www\mkjb\includes\aside.php on line 4 Call Stack # Time Memory Function Location 1 0.0008 140912 {main}( ) ..\register.php:0 2 0.0011 142336 include('C:\wamp\www\mkjb\includes\overall\overallheader.php') ..\register.php:1 3 0.0020 144880 include( 'C:\wamp\www\mkjb\includes\aside.php' ) ..\overallheader.php:8

 

could u help me fix this...i try different method it give same result

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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