User Management System (CodeIgniter Project – PHP MVC Framework)

At last I perfected this project to it’s completion, and I am really excited about showing it to you all.

So I will be adding here the wireframe images with attached notes that explain what the final project should be looking like, and after that I have a video showing how all the details of the wireframe were completed in the complete program.

With that I am sure you will not only understand the project and all of it’s details, but you will appreciate the beauty of how it all works.

Here is the wireframe:

MVC_Project_Wireframe

Here is a link to the project online:

http://mycodingadventure.info/CodeIgniter_Project/

Here is a link to github with the source files:

https://github.com/hkorik/Live_CodeIgniter_Project.git

A video of me showing how the program works:

Enjoy!

Restaurant Finder Project

Hello everyone, so here is a project I worked on for a two week period and it really covers lots of programming languages HTML, CSS, Jquery, Ajax, PHP with CodeIgniter framework, MySQL Database.

Below is a video all about it and how it all works, Enjoy!

Github Source Code:

https://github.com/hkorik/Restaurant-Finder-Project-09-18-2013.git

OOP Project

Well well, after programming so much with out OOP, when we learned it, it actually made so much more sense to program with it. So instead of every function being it’s own “being”, we put the functions and variables assosiated with one “concept” in one class, and when you need to use that function again and again all you need to do is create an instance of that class by saying $instance_name = new class_name();

And choosing which function or variable you like to use in that specific class with a “->”. It’s that simple!

So here I practiced my OOP with creating a application which allows users to either log in or register, after logged on they are taken to a profile page where they see two lists a list of other names of people that are registered and a list of those that befriended them. They have the option of befriending new friends by clicking on the button near their names in the registered list, and automatically the list of friends will update itself and the button in the registered list will turn in to the word that says “Friends”.

The register/login page:Image

The profile page:Image

Github Source Code:
https://github.com/hkorik/OOP_Project.git

login.php Code:
<?php

	include("connection.php");

	if(isset($_SESSION['logged_in']))
	{
		header("Location: home.php");
	}

?>

<!doctype html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Log in - Registration Page</title>
	<link rel="stylesheet" type="text/css" href="CSS/styles.css" />
	<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css">
</head>
<body>
	<div id="wrapper">
		<h1>Log in and Registration Page</h1>
		<!-- Registration left box -->
		<div id="registration_box" class="float_left">
			<h2>Register</h2>
			<?php
				if(isset($_SESSION['register_errors']))
				{
					foreach($_SESSION['register_errors'] as $error)
					{
						echo "<p class='error_message'>$error</p>";
					}
				}

				else if(isset($_SESSION['register_message']))
				{
					echo "<p class='success_message'>{$_SESSION['register_message']}</p>";
					unset($_SESSION['register_message']);
				}
			?>
			<form action="process.php" method="post">
				<input type="hidden" name="action" value="register" />
				<div class="<?php if(isset($_SESSION['register_errors']['first_n_error'])) echo 'field_block'; ?>">
					<label for="first_name">First Name *</label><br/>
					<input type="text" name="first_name" id="first_name" placeholder="First Name" />
				</div>
				<div class="<?php if(isset($_SESSION['register_errors']['last_n_error'])) echo 'field_block'; ?>">
					<label for="last_name">Last Name *</label><br/>
					<input type="text" name="last_name" id="last_name"placeholder="Last Name" />
				</div>
				<div class="<?php if(isset($_SESSION['register_errors']['email_error'])) echo 'field_block'; ?>">
					<label for="email">Email *</label><br/>
					<input type="text" name="email" id="email" placeholder="Email" />
				</div>	
				<div class="<?php if(isset($_SESSION['register_errors']['pw_error'])) echo 'field_block'; ?>">
					<label for="password">Password *</label><br/>
					<input type="password" name="password" id="password" placeholder="Password" />
				</div>
				<input class="btn btn-primary" type="submit" value="Register" />
			</form>
			<?php unset($_SESSION['register_errors']); ?>
		</div>
		<!-- Login right box -->
		<div id="login_box" class="float_right">
			<h2>Login</h2>
			<?php
				if(isset($_SESSION['login_errors']))
				{
					foreach($_SESSION['login_errors'] as $error)
					{
						echo "<p class='error_message'>$error</p>";
					}
				}

				else if(isset($_SESSION['message']))
				{
					
				}
			?>
			<form action="process.php" method="post">
				<input type="hidden" name="action" value="login" />
				<div class="<?php if(isset($_SESSION['login_errors']['email_error'])) echo 'field_block'; ?>">
					<label for="email">Email *</label><br/>
					<input type="text" name="email" id="email" placeholder="Email" />
				</div>	
				<div class="<?php if(isset($_SESSION['login_errors']['pw_error'])) echo 'field_block'; ?>">
					<label for="password">Password *</label><br/>
					<input type="password" name="password" id="password" placeholder="Password" />
				</div>
				<input class="btn btn-primary" type="submit" value="Login" />
			</form>
			<?php unset($_SESSION['login_errors']); ?>
		</div>
	</div>
</body>
</html>

home.php Code:

<?php
	
	include("connection.php");
	
	if(!isset($_SESSION['logged_in']))
	{
		header("Location: login.php");
	}

?>
<!doctype html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Home Page</title>
	<link rel="stylesheet" type="text/css" href="CSS/styles.css" />
	<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
	<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css">
	<link rel="stylesheet" media="all" type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/themes/ui-lightness/jquery-ui.css" />
	<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js"></script>
	<script type="text/javascript">
		$(document).ready(function(){

			 $('#user_form').submit(function(){
                var form = $(this);
                $.post(
                    form.attr('action'),
                    form.serialize(),
                    function(data){
                        $('#users_list').html(data);
                    },
                     'json');
               return false;
            });
            
           $('#user_form').submit();

            $('#friend_form').submit(function(){
                var form = $(this);
                $.post(
                    form.attr('action'),
                    form.serialize(),
                    function(data){
                        $('#friends_list').html(data);
                    }, 
                    'json');
                return false;
            });
            
            $('#friend_form').submit();

			$(document).on('submit', '.add_friend_form', function(){
				var form = $(this);
				$.post(
					form.attr('action'),
					form.serialize(),
					function(data){
						$('#user_form').submit();
	                    $('#friend_form').submit();
					},
					'json');
				return false;
			});
			
		});

	 </script>
</head>
<body>
	<div id="wrapper_home">
		<div id="header">
			<p class="float_left">Welcome <?php echo "{$_SESSION['user']['first_name']}" ?>!</p>
			<p class="float_right"><a class="btn btn-danger" href="process.php">Log off</a></p>
			<p class="clear"><?php echo "{$_SESSION['user']['email']}" ?></p>
		</div>
		<div id="main">
			<h3>List of Friends</h3>
			<form id="friend_form" action="process.php" method="post">
				<input type="hidden" name="action" value="friends" />
			</form>
			<table class="table">
				<thead>
					<th>Name</th>
					<th>Email</th>
				</thead>
				<tbody id="friends_list">
					
				</tbody>
			</table>

			<h3>List of Users who subscribed to Friend Finder</h3>
			<form id="user_form" action="process.php" method="post">
				<input type="hidden" name="action" value="users" />
			</form>	
			<table class="table">
				<thead>
					<th>Name</th>
					<th>Email</th>
					<th>Action</th>
				</thead>
				<tbody id="users_list">
					
				</tbody>
			</table>
		</div>
	</div>
</body>
</html>

styles.css Code:

*{
	margin: 0px;
	padding: 0px;
}
.float_left{
	float:left;
}
.float_right{
	float:right;
}
.clear{
	clear: both;
}
#wrapper{
	padding: 15px;
	width:600px;
	margin: 10px auto;
}
#wrapper h1{
	text-align: center;
}
	/*Pop up Messages styling*/
	.success_message{
		color: green;
	}
	.error_message{
		color: red;
	}
	.highlighted{
		border:1px solid red;
	}
	.field_block{
		border:1px solid red;
		width:160px;
		margin-bottom:5px;
	}
	/* Registration left box*/
	#registration_box {
		border:1px solid black;
		padding: 5px;
		margin-top: 20px;
		margin-left: 30px;
		width:200px;
	}
		#registration_box h2{
			color:grey;
			text-decoration: underline;
		}
		#registration_box form{
			margin-top:10px; 
		}
		#registration_box input{
			margin-bottom: 10px;
		}
	/* Login right box*/	
	#login_box {
		border:1px solid black;
		padding: 5px;
		margin-top: 20px;
		margin-right: 30px;
		width:200px;
	}
		#login_box h2{
			color:grey;
			text-decoration: underline;
		}
		#login_box form{
			margin-top:10px; 
		}
		#login_box input{
			margin-bottom: 10px;
		}
#wrapper_home{
	padding: 15px;
	width:600px;
	margin: 10px auto;
}
	#wrapper_home #header{
		height: 40px;

	}
		#wrapper_home #header p{
			font-size: 18px;
		}
	#wrapper_home #main{
		margin: 20px 0px 0px 0px;
	}
		#wrapper_home #main h3{
			border-bottom: 1px solid black;
			display: inline-block;
		}
		#wrapper_home #main table{
			margin: 15px 0px;
			border: 1px solid grey;
		}
		#wrapper_home #main th{
			border: 1px solid grey;
			width:150px;
		}
		#wrapper_home #main td{
			padding: 4px;
		}

constant.php Code:

<?php

//define constants for db_host, db_user, db_pass, and db_database
//adjust the values below to match your database settings
define('DB_HOST', 'localhost');
define('DB_USER', 'root');
define('DB_PASS', ''); //set DB_PASS as 'root' if you're using MAMP
define('DB_DATABASE', 'friends');

?>

connection.php Code:

<?php

include("constant.php");
session_start();

class Database{

	public function __construct()
	{
		//connect to database host
		$connection = mysql_connect(DB_HOST, DB_USER, DB_PASS) or die('Could not connect to the database host (please double check the settings in connection.php): ' . mysql_error());

		//connect to the database
		$db_selected = mysql_select_db(DB_DATABASE, $connection) or die ('Could not find a database with the name "'.DB_DATABASE.'" (please double check your settings in connection.php): ' . mysql_error());
	}

	//fetches all records from the query and returns an array with the fetched records
	function fetch_all($query)
	{
		 $data = array();

		 $result = mysql_query($query);
		 while($row = mysql_fetch_assoc($result))
		 {
		  $data[] = $row;
		 }
		 return $data;
	}

	//fetch the first record obtained from the query
	function fetch_record($query)
	{
		 $result = mysql_query($query);
		 return mysql_fetch_assoc($result);
	}

}

?>

process.php Code:

<?php

include("connection.php");
class Process{

	var $run_database;
	var $html;
	var $table1;

	function __construct()
	{
		$this->run_database = new Database();

		//When user registers - run register function
		if(isset($_POST['action']) and $_POST['action'] == "register")
		{
			$this->register_action();
		}
		//When user logs in - run login function
		else if (isset($_POST['action']) and $_POST['action'] == "login") 
		{
			$this->login_action();
		}
		elseif(isset($_POST['action']) and $_POST['action'] == "friends")
		{
			$this->get_friends_list();
			$data = $this->table1;
			echo json_encode($data);
		}
		elseif(isset($_POST['action']) and $_POST['action'] == "users")
		{
			$this->get_users_list();
			$data = $this->html;
			echo json_encode($data);
		}
		else if(isset($_POST['action']) and $_POST['action'] == "users_id")
		{
			$this->add_friend();
			$added = "added friend";
			echo json_encode($added);
		}
		else
		{
			session_destroy();
			header("Location: login.php");
		}
	}
	
	function register_action()
	{	
		$errors = NULL;

		//Email validation
		if(empty($_POST['email']))
		{
			$errors['email_error'] = "Error: Email address cannot be blank!";
		}
		else if(!filter_var($_POST['email'], FILTER_VALIDATE_EMAIL))
		{
			$errors['email_error'] = "Error: Email should be in valid format!";
		}

		//First name validation
		if(empty($_POST['first_name']))
		{
			$errors['first_n_error'] = "Error: First name field cannot be blank!";
		}
		else if (preg_match('#[0-9]#', $_POST['first_name'])) 
		{
			$errors['first_n_error'] = "Error: First name cannot contain numbers!";
		}

		//Last name validation
		if(empty($_POST['last_name']))
		{
			$errors['last_n_error'] = "Error: Last name field cannot be blank!";
		}
		else if (preg_match('#[0-9]#', $_POST['last_name'])) 
		{
			$errors['last_n_error'] = "Error: Last name cannot contain numbers!";
		}

		//Password validation
		if(empty($_POST['password']))
		{
			$errors['pw_error'] = "Error: Password field cannot be blank!";
		}
		else if(strlen($_POST['password']) < 6)
		{
			$errors['pw_error'] = "Error: Password must be greater than 6 charecters";
		}

		//if there are any errors
		if(count($errors) > 0)
		{
			$_SESSION['register_errors'] = $errors;
			header("Location: login.php");
		}

		// if everything is correct!
		else
		{
			//check if user email exists
			$check_user = "SELECT * FROM users WHERE email = '{$_POST['email']}'";
			$user_exist = $this->run_database->fetch_record($check_user);

			// if no one has that email address
			if($user_exist == NULL)
			{
				$new_user = "INSERT INTO users (first_name, last_name, email, password, created_at) VALUES ('{$_POST['first_name']}','{$_POST['last_name']}','{$_POST['email']}','" . md5($_POST['password']) . "', now() )";

				mysql_query($new_user);

				$check_user_info = "SELECT * FROM users WHERE email = '{$_POST['email']}' AND password = '" . md5($_POST['password']) . "'";

				$user_info = $this->run_database->fetch_record($check_user_info);

				$_SESSION['user']['id'] = $user_info['id'];
				$_SESSION['user']['first_name'] = $user_info['first_name'];
				$_SESSION['user']['last_name'] = $user_info['last_name'];
				$_SESSION['user']['email'] = $user_info['email'];
				$_SESSION['logged_in'] = TRUE;

				if($_SESSION['logged_in'] == TRUE)
				{
					header("Location: home.php?=" . $_SESSION['user']['id']);
				}
				
			}
			// if email already exists
			else
			{
				$errors['email_error'] = "Error: Email {$_POST['email']} is already in use!";
				$_SESSION['register_errors'] = $errors;
				header("Location: login.php");
			}
		}
	}

	//login button function
	function login_action()
	{	
		$errors_login = NULL;

		//Email validation
		if(empty($_POST['email']))
		{
			$errors_login['email_error'] = "Error: Email address cannot be blank!";
		}
		else if(!filter_var($_POST['email'], FILTER_VALIDATE_EMAIL))
		{
			$errors_login['email_error'] = "Error: Email should be in valid format!";
		}

		//Password validation
		if(empty($_POST['password']))
		{
			$errors_login['pw_error'] = "Error: Password field cannot be blank!";
		}
		else if(strlen($_POST['password']) < 6)
		{
			$errors_login['pw_error'] = "Error: Password length must be at least 6 charecters!";
		}

		//if there are any error
		if(count($errors_login) > 0)
		{
			$_SESSION['login_errors'] = $errors_login;

			header("Location: login.php");
		}

		// if everything is correct!
		else
		{
			$check_user_info = "SELECT * FROM users WHERE email = '{$_POST['email']}' AND password = '" . md5($_POST['password']) . "'";
			
			$user_info = $this->run_database->fetch_record($check_user_info);
			
			if($user_info != NULL)
			{
				$_SESSION['user']['id'] = $user_info['id'];
				$_SESSION['user']['first_name'] = $user_info['first_name'];
				$_SESSION['user']['last_name'] = $user_info['last_name'];
				$_SESSION['user']['email'] = $user_info['email'];
				$_SESSION['logged_in'] = TRUE;

				if($_SESSION['logged_in'] == TRUE)
				{
					header("Location: home.php?=" . $_SESSION['user']['id']);	
				}

			}
			else
			{
				$errors[] = "Error: The information entered does not match any of our records!";
				$_SESSION['login_errors'] = $errors;
				header("Location: login.php");
			}	
		}
	}

	function get_users_list()
	{
		$friend_status = array();

		// query to get all the friends
		$friends_query = "SELECT * FROM friends";
		$friends = $this->run_database->fetch_all($friends_query);

		// check if the current user's id exists in the friends table
		foreach($friends as $friend)
		{
			if($_SESSION['user']['id'] == $friend['user_id'])
			{
				$friend_status[$friend['friend_id']] = TRUE;
			}
		}

		// store it in a another array $friend_status
		$users_query = "SELECT id, first_name, last_name, email
				  FROM users
				  WHERE users.id != '{$_SESSION['user']['id']}'";
		$users_list = $this->run_database->fetch_all($users_query);

		foreach($users_list as $user)
		{
			$this->html .= "<tr>";
			$this->html .= "<td>{$user['first_name']} {$user['last_name']}</td>
								<td>{$user['email']}</td>";

			if(isset($friend_status[$user['id']]))
			{
				$this->html .= "<td>Friends</td>";
			}
			else
			{
				$this->html .= "<td>
									<form class='add_friend_form' action='process.php' method='post'>
									<input type='hidden' name='action' value='users_id'>
									<input type='hidden' name='user_id' value='{$user['id']}'>
									<input class='btn btn-success' type='submit' value='Add as Friend' />
									</form>
								</td>";
			}

			$this->html .= "</tr>";				
		}
	}

	function get_friends_list()
	{
		$query = "SELECT users.first_name, users.last_name, users.email
				FROM users
				LEFT JOIN friends
				ON friends.friend_id = users.id
				WHERE friends.user_id = '{$_SESSION['user']['id']}'";

		$friends_list = $this->run_database->fetch_all($query);

		foreach($friends_list as $friend)
		{
			$this->table1 .= "<tr>
								<td>{$friend['first_name']} {$friend['last_name']}</td>
								<td>{$friend['email']}</td></tr>";
		}
	}

	function add_friend()
	{
		$query = "INSERT INTO friends (user_id, friend_id) VALUES ('{$_SESSION['user']['id']}', '{$_POST['user_id']}'), ('{$_POST['user_id']}', '{$_SESSION['user']['id']}')";

		mysql_query($query);
	}
}

$process = new Process();

?>

Ajax Project

So here we came to the awesome tool of Ajax! We can actually see the results that are coming from our back-end functionality with out having to refresh the page, that is so cool!! For example as we type we can see the changes being made right in front of our eyes, although the changes are coming from our database in the back-end. Let’s take a look at some of the projects that display the functionality of Ajax.

Here I worked off a sample database from a company that would create websites for clients and generate leads for their clients through the websites that were created for them. The database includes all the clients information, the websites that were created for them, time and date of creation, information of the leads each website generated, and time and date when the leads were generated.

On the page here we display the leads information. id, first name, last name, email and time registered.

When there are more then 10 leads it displays it with pagination. The names are in alphabetical order by last name. As one types in the name input field the information in the list changes, as well when the “From” and “To” dates get changed the list changes appropriately with Ajax!

The full list with pagination:
Full_list

The list when started to type in the name field:typing_name

The list when filled in the date fields as well:name_dates

Github Source Codes:
https://github.com/hkorik/Ajax_Project.git

index.php Code:
<?php

	require("connection.php");

?>

<!doctype html>
<html lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
	<title>Ajax</title>
	<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
	<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css">
	<link rel="stylesheet" media="all" type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/themes/ui-lightness/jquery-ui.css" />
	<link rel="stylesheet" type="text/css" href="styles.css">
	<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js"></script>
	<script type="text/javascript">

    $(document).ready(function(){

    	$('.date').datepicker({
    		dateFormat: "yy-mm-dd"
    	});

    	$('.date').change(function(){
    		$("#hidden").val('1');
    		$('#test_form').submit();
    	});

    	$('#search_text').keyup(function(){
    		$("#hidden").val('1');
    		$('#test_form').submit();
    	});

    	$('#test_form').submit(function(){
    		$.post(
    			$(this).attr('action'),
    			$(this).serialize(),
    			function(data){
    				$('#results').html(data.pages);
    				$('#results').append(data.html);

    				$("button").click(function(){
						$("#hidden").val($(this).attr('id'));
						// $("button").addClass('active');
						$("#test_form").submit();
					});
    			},
    			"json"
			);
			return false;
    	});

    	$('#test_form').submit();

    });
	</script>
</head>
<body>
	<div id="wrapper">
		<form id="test_form" action="process.php" method="post">
			<div class="form-group float_left">
				<input id="hidden" type="hidden" name="action" value="1">
				<label for="name">Name:</label>
				<input type="text" id="search_text" name="name">
			</div>
			<div class="form-group float_left">
				<label for="from_date">From:</label>
				<input class="date" id="from_date" type="text" name="from_date">
			</div>
			<div class="form-group float_left">
				<label for="to_date">To:</label>
				<input class="date" id="to_date" type="text" name="to_date">
			</div>
		</form>
		<div id="results" class="clear">

		</div>
	</div>
</body>
</html>

styles.css Code:

*{
	margin: 0px;
	padding: 0px;
}
.float_left{
	float: left;
}
.float_right{
	float: right;
}
.clear{
	clear: both;
}
.active{
	background-color: blue;
}
#wrapper{
	margin: 10px auto;
}
#test_form div{
	margin: 10px 20px 15px 20px;
}
#test_form label{
	margin: 0px 15px 0px 0px;
}

connection.php Code:

<?php

//define constants for db_host, db_user, db_pass, and db_database
//adjust the values below to match your database settings
define('DB_HOST', 'localhost');
define('DB_USER', 'root');
define('DB_PASS', ''); //set DB_PASS as 'root' if you're using MAMP
define('DB_DATABASE', 'lead_gen_business');

//connect to database host
$connection = mysql_connect(DB_HOST, DB_USER, DB_PASS) or die('Could not connect to the database host (please double check the settings in connection.php): ' . mysql_error());

//connect to the database
$db_selected = mysql_select_db(DB_DATABASE, $connection) or die ('Could not find a database with the name "'.DB_DATABASE.'" (please double check your settings in connection.php): ' . mysql_error());

//fetches all records from the query and returns an array with the fetched records
function fetch_all($query)
{
 $data = array();

 $result = mysql_query($query);
 while($row = mysql_fetch_assoc($result))
 {
  $data[] = $row;
 }
 return $data;
}

//fetch the first record obtained from the query
function fetch_record($query)
{
 $result = mysql_query($query);
 return mysql_fetch_assoc($result);
}

?>

process.php Code:


<?php

    require("connection.php");

    $data = array();
    $from_date = "1900-00-00";
    $to_date = "3000-00-00";

    $id = ($_POST['action'] * 10) - 10;

    if(isset($_POST['from_date']) AND ($_POST['from_date']) != "")
    {
        $from_date = $_POST['from_date'];
    }
    if(isset($_POST['to_date']) AND ($_POST['to_date']) != "")
    {
        $to_date = $_POST['to_date'];
    }

    $amount = "SELECT count(*) AS count FROM leads
    WHERE (first_name LIKE '{$_POST['name']}%' OR last_name LIKE '{$_POST['name']}%') AND (registered_datetime BETWEEN '{$from_date}%' AND '{$to_date}%')";

    $query = "SELECT * FROM leads
    WHERE (first_name LIKE '{$_POST['name']}%' OR last_name LIKE '{$_POST['name']}%') AND (registered_datetime BETWEEN '{$from_date}%' AND '{$to_date}%') ORDER BY last_name LIMIT {$id}, 10";

   $users = fetch_all($query);

   $amount_of_pages = fetch_record($amount);

   $total = ceil($amount_of_pages['count'] / 10);

   $page = "<ul id='pages'>";
   for($i = 1; $i <= $total; $i++)
   {
       $page .= "<li style='display: inline;'><button type='button' id='{$i}' class='btn btn-link'>{$i}</button></li>";
   }
   $page .= "</ul>";

   $html = "
        <table class='table'>
            <thead>
                <tr>
                   <th>leads_id</th>
                   <th>first_name</th>
                   <th>last_name</th>
                   <th>registered_datetime</th>
                   <th>email</th>
                </tr>
            </thead>
            <tbody>
        ";
  foreach($users as $user)
  {
        $html .= "
                <tr>
                    <td>{$user['leads_id']}</td>
                    <td>{$user['first_name']}</td>
                    <td>{$user['last_name']}</td>
                    <td>{$user['registered_datetime']}</td>
                    <td>{$user['email']}</td>
                </tr>
        ";
  }

  $html .= "
            </tbody>
        </table>
    ";

    $data['pages'] = $page;
    $data['html'] = $html;
    echo json_encode($data);

?>

PHP Advanced

Here I created a facebook style wall where a user can either register or log in. Then it comes to a page where it welcomes the user with his name and allows him to write a post and comment on his post or other posts. The posts are displayed in order of the latest post on top. The comments are ordered by the first comment on top. The name and date of the post/comments are also rendered on the page.

Github Source Codes:
https://github.com/hkorik/PHP_Project.git

Log in page:

Login

Log in code:

Login_code

Register page:

Register

Register code:

Register_code

Wall page:

Wall

Wall code:

Wall_code

DB Connection code:

Connection

Process code:

Process_code

Styles code:

Style

PHP Basics Part II

Here is a second one I practiced on. I wrote a program that created a checkerboard in HTML.

The outcome:

PHP_2

My code:

PHP_2_codes

PHP Basics Part I

Here we came to the most exciting part of programming- the variables, arrays and functions, the if/else statements, for loops and while loops, these and all the logic’s were the most enjoyable part of programming for me.

Here are a few of the fun assignments I worked on to practice my basic PHP skills.

The first one I created a program that displays a multiplication table using math, without putting the values in an array.

The outcome:

PHP_1

Here are my codes:

PHP_1_codes PHP_1_css

Week 3 – ERD Database Designing, mySQL Querying

Week number three started off the journey into the world of back-end development.

First we were introduced to database designing and creating Entity-Relationship Diagrams. We learned how to set up the tables and their different connections and how to organize the columns in the tables in their proper format.

After creating some ERD’s, we learned all about mySQL Queries. I practiced writing queries for many different types of databases.

Jquery Ninja Project

So here I had a really fun project to practice my Jquery skills.

We had two different images, one of a ninja and a second of a cat. We had to crop the two images in to five equal sections and program that when one clicked on one section of the ninja image, it would switch with the correct section of the cat image. Also, we had to program that the order of the sections of the image can be switched just by dragging it up and down (cool Jquery UI stuff :)).

Here is the outcome of my project:

Jquery_ninjaCatmixed

Here is the Code:

Image

Week 2 – Front-end Development

After the first week, we were introduced to the wonderful world of JQuery and JQueryUI where you really bring the UI/UX to a whole new level.

After mastering the skills on how to do it on our own, we then ended off the week with a Yellow Belt Exam where we had to recreate a webpage from scratch in just 4 hours!

Here is the webpage we were asked to complete:Image

I successfully passed my Yellow Belt Exam!

In the next post I will put up one of my projects I made with Jquery.

Archives