Sunday 9 June 2019

the recreation of thefacebook2004


Hi guys! I'm back with a new article  the recreation of thefacebook2004Thefacebook Clone is nothing more than an attempt to recreate the first version of Facebook was launched in 2003/2004 ,This project aims to be an advanced , lightweight and free clone, being written with PHP , HTML , CSS and with MySQL as data storage. we will discuss about Facebook is a social networking service launched as FaceMash in July 2003, but later changing to TheFacebook on February 4, 2004It was founded by Mark Zuckerberg with his college roommate and fellow Harvard University student Eduardo Saverin. The website's membership was initially limited by the founders to Harvard students, but was expanded to other colleges in the Boston area, the Ivy Leagueand gradually most universities in the United States and Canada,corporationsand by September 2006, to everyone with a valid email address along with an age requirement of being 13 and older

TheFacebook Clone
- Version : 1.0 

Files

index.php

terms.php

privacy.php

contact.php

social_net.php

search.php

profile.php

about.php

register.php

login.php

messages.php

read_message.php

send_message.php

edit_profile.php

edit_privacy.php

edit_account.php

edit_photo.php

my_friends.php

home.php

invite.php

faq.php

logout.php

Images

The recreation of the html, is being based only in images found on the internet.






 















 Hope this post will help you . If you enjoy my work then please share my posts with your buddies and anyone who might be interested in thefacebook2004

                                           coming soon  on Udemy

Wednesday 29 May 2019

Build Your Own Video Sharing Website LikeYouTube

Hi guys! I'm back with a new article  of how to build a video sharing website like youtube
 we will discuss about YouTube launched in 2005, no one could have imagined that it would become such a successful website. Today, YouTube is the #3 website in the world pulling in over 1 billion visitors each month...that's a lot of people. One of the biggest reasons why YouTube became so popular is because video is the most powerful way to present anything.
  Here are some amazing stats about YouTube:

More than 1 billion unique users visit YouTube each month
    Over 6 billion hours of video are watched each month on YouTube—that's almost an hour for every person on Earth
    100 hours of video are uploaded to YouTube every minute
    80% of YouTube traffic comes from outside the US
    YouTube is localized in 61 countries and across 61 languages
    According to Nielsen, YouTube reaches more US adults ages 18-34 than any cable network
    Millions of subscriptions happen each day. The number of people subscribing daily is up more than 3x since last year, and the number of daily subscriptions is up more than 4x since last year

 What is this article about?
This article will teach you step by step how to create a website similar to YouTube. So if you've ever wanted to launch a YouTube like site, you will be able to at the end of the article.

Who is this article for?
This article is for people, organizations agencies or companies that want to build their brand by presenting amazing video content. Users will be able to upload or import their videos through their admin panel, create playlists, give thumbs up or down for videos, embed videos, and so much more.
While it's a good idea to post your videos on YouTube, it would be just as good to drive a ton of traffic by having people visit your website and watching the videos without having to go somewhere else. This is great for SEO and brand visibility. 


 Monetizing Your Site
You will learn how to monetize your site with Google Adsense or banners simply by inserting your codes in whatever position you want to show ads. This will give you complete control over what ads show on your website.

Website and Video Optimization
This article will teach you how to optimize your site, menus, videos, and content pages. This will increase your visibility on search engines like Google, Bing and Yahoo!. 

Your website will have the following features:

video upload

video thumbnail generation

server side video conversion

full video player

likes + dislikes on videos

full comment system with likes/dislikes, replies etc.

video details editing

account creation

Easy-to-use interface inspired by YouTube

Front-end management for user and admin

Social media sharing (Facebook, Twitter, Google+, Email)

and much  more!

   Coming Soon

Wednesday 20 September 2017

Android Login Register With php and mysql

In this post we are going to learn about how to connect to MySQL Database from your Android Application and perform database operations. Here we create an android app that contain some login Activity through which the user can retrieve information from database and a registration Activity through which the user can add information into the database. 

First you need to have the following components installed in your development machine. 
1. Database : Here we use the MySQL database.
2. Web Server : Here we use the Apache Web Server.
3. Server side Scripting Language :  Here we use PHP for server side scripting.
4. Android Development environment : You must install android sdk and android studio.  

I recommend you to download and install WAMPSERVER. The wamp server installer contains the following components.
Apache Server Application
MySQL Database
PHP/phpMyAdmin

First we have to create the database and table in MySQL. You can use the phpMyAdmin for mange your MySQL databases. Here our database name is "webappdb" and table name is "user_info".  
The table contains three columns "name", "user_name" and "user_pass". 

For our android application create a new folder inside the public directory of the wamp server and name the folder as "webapp".
First we have to write the needed php scripts and put it in the public directory of the wamp server. Here we need three php scripts, first one is for establish a connection with the database, second one for add informations into database and the last one for retrieve informations.

1. init.php
 <?php  
 $db_name = "webappdb";  
 $mysql_user = "root";  
 $mysql_pass = "root";  
 $server_name = "localhost";  
 $con = mysqli_connect($server_name,$mysql_user,$mysql_pass,$db_name);  
 ?>  

2. register.php
 <?php  
 require "init.php";  
 $name = $_POST["user"];  
 $user_name = $_POST["user_name"];  
 $user_pass = $_POST["user_pass"];  
 $sql_query = "insert into user_info values('$name','$user_name','$user_pass');";  
 ?>  
3. login.php
 <?php  
 require "init.php";  
 $user_name = $_POST["login_name"];  
 $user_pass =  $_POST["login_pass"];  
 $sql_query = "select name from user_info where user_name like '$user_name' and user_pass like '$user_pass';";  
 $result = mysqli_query($con,$sql_query);  
 if(mysqli_num_rows($result) >0 )  
 {  
 $row = mysqli_fetch_assoc($result);  
 $name =$row["name"];  
 echo "Login Success..Welcome ".$name;  
 }  
 else  
 {   
 echo "Login Failed.......Try Again..";  
 }  
 ?> 
Create an android application contain a Login Activity and Register Activity. 

activity_main.xml (Login Activity layout)
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"  
   xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"  
   android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"  
   android:paddingRight="@dimen/activity_horizontal_margin"  
   android:paddingTop="@dimen/activity_vertical_margin"  
   android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity"  
   android:background="#0BB990"  
   android:orientation="vertical"  
   >  
   <TextView  
     android:layout_width="wrap_content"  
     android:layout_height="wrap_content"  
     android:text="Login Form"  
     android:textAppearance="?android:textAppearanceLarge"  
     android:textStyle="bold"  
     android:layout_gravity="center_horizontal"  
     android:layout_marginTop="10dp"  
     />  
   <EditText  
     android:layout_width="250dp"  
     android:layout_height="wrap_content"  
     android:hint="User Name"  
     android:id="@+id/user_name"  
     android:layout_gravity="center_horizontal"  
     android:layout_marginTop="70dp"  
     />  
   <EditText  
     android:layout_width="250dp"  
     android:layout_height="wrap_content"  
     android:hint="Password"  
     android:id="@+id/user_pass"  
     android:layout_gravity="center_horizontal"  
     android:layout_marginTop="20dp"  
     android:inputType="textPassword"  
     />  
   <Button  
     android:layout_width="100dp"  
     android:layout_height="wrap_content"  
     android:text="Login"  
     android:layout_gravity="center_horizontal"  
     android:layout_marginTop="10dp"  
     android:onClick="userLogin"  
   />  
   <Button  
     android:layout_width="wrap_content"  
     android:layout_height="wrap_content"  
     android:text="Register Now"  
     android:layout_gravity="center_horizontal"  
     android:layout_marginTop="50dp"  
     android:onClick="userReg"  
     />  
 </LinearLayout>  
android-localhost
register_layout.xml (Register Activity Layout)
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"  
   xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"  
   android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"  
   android:paddingRight="@dimen/activity_horizontal_margin"  
   android:paddingTop="@dimen/activity_vertical_margin"  
   android:paddingBottom="@dimen/activity_vertical_margin"  
   tools:context="com.easyway2in.mysqlconnect.Register"  
   android:orientation="vertical"  
   android:background="#0BB990"  
   >  
   <TextView  
     android:layout_width="wrap_content"  
     android:layout_height="wrap_content"  
     android:text="Registration Form"  
     android:textAppearance="?android:textAppearanceLarge"  
     android:textStyle="bold"  
     android:layout_gravity="center_horizontal"  
     android:layout_marginTop="10dp"  
     />  
   <EditText  
     android:layout_width="250dp"  
     android:layout_height="wrap_content"  
     android:hint="Name"  
     android:id="@+id/name"  
     android:layout_gravity="center_horizontal"  
     android:layout_marginTop="40dp"  
     />  
   <EditText  
     android:layout_width="250dp"  
     android:layout_height="wrap_content"  
     android:hint="User Name"  
     android:id="@+id/new_user_name"  
     android:layout_gravity="center_horizontal"  
     android:layout_marginTop="20dp"  
     />  
   <EditText  
     android:layout_width="250dp"  
     android:layout_height="wrap_content"  
     android:hint="Password"  
     android:id="@+id/new_user_pass"  
     android:layout_gravity="center_horizontal"  
     android:layout_marginTop="20dp"  
     android:inputType="textPassword"  
     />  
   <Button  
     android:layout_width="130dp"  
     android:layout_height="wrap_content"  
     android:text="Register"  
     android:layout_gravity="center_horizontal"  
     android:layout_marginTop="30dp"  
     android:onClick="userReg"  
     />  
 </LinearLayout>  

android-database-tutorial

In this tutorial we use the HttpUrlConnection instead of HttpClient. HttpClient is deprecated form API level 22.

Here the server is localhost and we test the application on an android virtual device. We need two URL. First one for registration purpose and the second one is for user Login.

Register URL : ""http://10.0.2.2/webapp/register.php";
Login URL : "http://10.0.2.2/webapp/login.php";

Here we use the IP (10.0.2.2) -because the android virtual device use this default IP for connect to the localhost. You can also use your local computer IP address. This application use an AsyncTask to perform the server operations. 

MainActivity.java
 package com.easyway2in.mysqldbdemo;  
 import android.app.Activity;  
 import android.content.Intent;  
 import android.os.StrictMode;  
 import android.support.v7.app.ActionBarActivity;  
 import android.os.Bundle;  
 import android.view.Menu;  
 import android.view.MenuItem;  
 import android.view.View;  
 import android.widget.EditText;  
 public class MainActivity extends Activity{  
   EditText ET_NAME,ET_PASS;  
   String login_name,login_pass;  
   @Override  
   protected void onCreate(Bundle savedInstanceState) {  
     super.onCreate(savedInstanceState);  
     setContentView(R.layout.activity_main);  
    ET_NAME = (EditText)findViewById(R.id.user_name);  
     ET_PASS = (EditText)findViewById(R.id.user_pass);  
   }  
 public void userReg(View view)  
 {  
   startActivity(new Intent(this,Register.class));  
 }  
   public void userLogin(View view)  
   {  
   login_name = ET_NAME.getText().toString();  
     login_pass = ET_PASS.getText().toString();  
     String method = "login";  
     BackgroundTask backgroundTask = new BackgroundTask(this);  
     backgroundTask.execute(method,login_name,login_pass);  
   }  
 }  


BackgroundTask.java
 package com.easyway2in.mysqldbdemo;  
 import android.app.AlertDialog;  
 import android.content.Context;  
 import android.os.AsyncTask;  
 import android.widget.Toast;  
 import java.io.BufferedReader;  
 import java.io.BufferedWriter;  
 import java.io.IOException;  
 import java.io.InputStream;  
 import java.io.InputStreamReader;  
 import java.io.OutputStream;  
 import java.io.OutputStreamWriter;  
 import java.net.HttpURLConnection;  
 import java.net.MalformedURLException;  
 import java.net.URL;  
 import java.net.URLEncoder;  
 /**  
  * Created by prabeesh on 7/14/2015.  
  */  
 public class BackgroundTask extends AsyncTask<String,Void,String> {  
  AlertDialog alertDialog;  
   Context ctx;  
   BackgroundTask(Context ctx)  
   {  
    this.ctx =ctx;  
   }  
   @Override  
   protected void onPreExecute() {  
   alertDialog = new AlertDialog.Builder(ctx).create();  
     alertDialog.setTitle("Login Information....");  
   }  
   @Override  
   protected String doInBackground(String... params) {  
     String reg_url = "http://10.0.2.2/webapp/register.php";  
     String login_url = "http://10.0.2.2/webapp/login.php";  
     String method = params[0];  
     if (method.equals("register")) {  
       String name = params[1];  
       String user_name = params[2];  
       String user_pass = params[3];  
       try {  
         URL url = new URL(reg_url);  
         HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection();  
         httpURLConnection.setRequestMethod("POST");  
         httpURLConnection.setDoOutput(true);  
         //httpURLConnection.setDoInput(true);  
         OutputStream OS = httpURLConnection.getOutputStream();  
         BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter(OS, "UTF-8"));  
         String data = URLEncoder.encode("user", "UTF-8") + "=" + URLEncoder.encode(name, "UTF-8") + "&" +  
             URLEncoder.encode("user_name", "UTF-8") + "=" + URLEncoder.encode(user_name, "UTF-8") + "&" +  
             URLEncoder.encode("user_pass", "UTF-8") + "=" + URLEncoder.encode(user_pass, "UTF-8");  
         bufferedWriter.write(data);  
         bufferedWriter.flush();  
         bufferedWriter.close();  
         OS.close();  
         InputStream IS = httpURLConnection.getInputStream();  
         IS.close();  
         //httpURLConnection.connect();  
         httpURLConnection.disconnect();  
         return "Registration Success...";  
       } catch (MalformedURLException e) {  
         e.printStackTrace();  
       } catch (IOException e) {  
         e.printStackTrace();  
       }  
     }  
     else if(method.equals("login"))  
     {  
       String login_name = params[1];  
       String login_pass = params[2];  
       try {  
         URL url = new URL(login_url);  
         HttpURLConnection httpURLConnection = (HttpURLConnection)url.openConnection();  
         httpURLConnection.setRequestMethod("POST");  
         httpURLConnection.setDoOutput(true);  
         httpURLConnection.setDoInput(true);  
         OutputStream outputStream = httpURLConnection.getOutputStream();  
         BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter(outputStream,"UTF-8"));  
       String data = URLEncoder.encode("login_name","UTF-8")+"="+URLEncoder.encode(login_name,"UTF-8")+"&"+  
           URLEncoder.encode("login_pass","UTF-8")+"="+URLEncoder.encode(login_pass,"UTF-8");  
         bufferedWriter.write(data);  
         bufferedWriter.flush();  
         bufferedWriter.close();  
         outputStream.close();  
         InputStream inputStream = httpURLConnection.getInputStream();  
         BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream,"iso-8859-1"));  
         String response = "";  
         String line = "";  
         while ((line = bufferedReader.readLine())!=null)  
         {  
           response+= line;  
         }  
         bufferedReader.close();  
         inputStream.close();  
         httpURLConnection.disconnect();  
         return response;  
       } catch (MalformedURLException e) {  
         e.printStackTrace();  
       } catch (IOException e) {  
         e.printStackTrace();  
       }  
     }  
     return null;  
   }  
   @Override  
   protected void onProgressUpdate(Void... values) {  
     super.onProgressUpdate(values);  
   }  
   @Override  
   protected void onPostExecute(String result) {  
    if(result.equals("Registration Success..."))  
    {  
      Toast.makeText(ctx, result, Toast.LENGTH_LONG).show();  
    }  
     else  
    {  
     alertDialog.setMessage(result);  
      alertDialog.show();  
    }  
   }  
 }  

Add the Internet permission in Manifest file.
 <uses-permission android:name="android.permission.INTERNET"></uses-permission>"  
   
This is how an android application connect to MySQL database run on a remote server and perform basic database operations. I hope you got the concepts. Please share your experience via comments.

Monday 20 February 2017

Simple Way to connect database with mysql, MySQLi , pdo in php

Mysql database connection

$database_host = 'localhost'; // database host name
// if using port then add port $database_host = 'localhost:3036';  
$database_user = 'database_user'; // database user name
$database_pass = 'database_password'; // database user password

// connect with database
$database_conn = mysql_connect($database_host, $database_user, $database_pass);

// check database connection 
if(! $database_conn )
{
    // error in database connection
    die('Could not connect to database : ' . mysql_error()); 

// connected to database
echo 'Connected successfully with database'; 

// close connection with Mysql database
mysql_close($database_conn);  

MySQLi Object-Oriented database connection

$database_host = 'localhost'; // database host name
// if using port then add port $database_host = 'localhost:3036';  
$database_user = 'database_user'; // database user name
$database_pass = 'database_password'; // database user password

// connect with database
$database_conn = new mysqli($database_host, $database_user, $database_pass);

// check database connection 
if ($database_conn->connect_error) 
{   
    // error in database connection
    die("Could not connect to database : " . $database_conn->connect_error);


// connected to database
echo 'Connected successfully with database';

// close connection with MySQLi database
$database_conn->close();

MySQLi Procedural database connection

$database_host = 'localhost'; // database host name
// if using port then add port $database_host = 'localhost:3036';  
$database_user = 'database_user'; // database user name
$database_pass = 'database_password'; // database user password

// connect with database
$database_conn = mysqli_connect($database_host, $database_user, $database_pass);

// check database connection 
if (!$database_conn) 
{
    // error in database connection
    die("Could not connect to database : " . mysqli_connect_error());
}

// connected to database
echo 'Connected successfully with database';

// close connection with MySQLi Procedural
mysqli_close($database_conn);

PDO database connection

$database_host = 'localhost'; // database host name    
$database_user = 'database_user'; // database user name
$database_pass = 'database_password'; // database user password
$database_name = 'your_database_name'; // database name

try
{
    $database_conn = new PDO("mysql:host=$database_host;dbname=$database_name", $database_user, $database_pass);
    // if using port then use port id in PDO  
    //$database_conn = new PDO('mysql:host=$database_host;port=5432;dbname=$database_name', $database_user, $database_pass);
     
    // exception for PDO connection error
    $database_conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
     
    // connected to database
    echo 'Connected successfully with database';
}
catch(PDOException $exception)
{
    // error in database connection
    echo "Could not connect to database : " . $exception->getMessage(); // exception
}

// close connection with PDO
$database_conn = null;