i want a simple php script for user management system

hai
i want a simple php script for manage my customers. every customer with a specific page and access only with login and admin can give messages to every customer.
i am try to crate a user login page. but i cant create user specific page.
i am just started to study php and sql. please help me…

This is a place where people go to get help with their code, not where people will write your code for you. You best bet if you want this done is to hire a programmer.

This sounds like something that could be handled pretty easily with a wordpress plugin (https://wordpress.org/plugins/wp-members/) , or perhaps even just wordpress alone (http://codex.wordpress.org/Registered_User_Features)

This should get you started…

[php]<?php
class User {

public function add($name, $email){
	$con = get_connection();
	$sql = '
		INSERT INTO user( "name", "email" )
		VALUES( :n, :e );
	';
	try {
		$stmt = $con->prepare( $sql );
		$stmt->bindParam( ':n', $name );
		$stmt->bindParam( ':e', $email );
		return array( 'status' => true, 'message' => 'User added.' );
	}
	catch( PDO::Exception $e ){
		return array( 'status' => false, 'message' => $e->getMessage() );
	}
}

public function update($uid, $name, $email){
	$con = get_connection();
	$sql = '
		UPDATE user
		SET name = :n, email = :e
		WHERE user_id = :uid
	';
	try {
		$stmt = $con->prepare( $sql );
		$stmt->bindParam( ':n', $name );
		$stmt->bindParam( ':e', $email );
		$stmt->bindParam( ':uid', $uid );
		$stmt->execute();
		return array( 'status' => true, 'message' => 'User updated.' );
	}
	catch( PDO::Exception $e ){
		return array( 'status' => false, 'message' => $e->getMessage() );
	}
}

public function get($uid){
	$con = get_connection();

	$sql = '
		SELECT *
		FROM user
		WHERE user_id = :uid
	';
	$stmt = $con->prepare( $sql );
	$stmt->bindParam( ':uid', $uid );
	$stmt->execute();
	$user = $stmt->fetch( PDO::FETCH_ASSOC );

	return $user;
}

public function remove($uid){
	$con = get_connection();

	$sql = '
		DELETE
		FROM user
		WHERE user_id = :uid
	';
	$stmt = $con->prepare( $sql );
	$stmt->bindParam( ':uid', $uid );
	$stmt->execute();
		return array( 'status' => true, 'message' => 'User removed.' );
	}
	catch( PDO::Exception $e ){
		return array( 'status' => false, 'message' => $e->getMessage() );
	}

}

}
?>
[/php]

****** This was written in 10 minutes and does not include the database connection ******
****** I also did not test this code in any way, like Strider64 said, this is a place to get help, not provide. If you would like me to create you an actual database and full blown user management system, I would be happy to do so for a fee. You can PM me if you would like to further discuss! ******

Sponsor our Newsletter | Privacy Policy | Terms of Service