Showing posts with label website development. Show all posts
Showing posts with label website development. Show all posts

Thursday, October 17, 2019

Create a eCommerce site without coding in 15 mins in hindi




In this video, you will learn how to setup E-commerce or Shopping Sites without coding using WordPress hosting. Firstly, we will buy hosting using Godaddy then will set up WordPress and login into the dashboard and then set up the title of the site and set up the Woocommcerce To learn Woocommerce check my video tutorial: https://www.youtube.com/watch?v=O0ZZ-... #SetUp #EcommerceSite #WithoutCoding

Sunday, January 14, 2018

Write an IOT application that controls LED with ON and OFF button using Windows IOT

-------------------------------------------------------------------------
Apparatus Required:
1 LED,2 jumper wires,1 resistor,Raspberry pi,breadboard
------------------------------------------------------------------------
XAML
--------------------------------------------------------------------------
<Page
    x:Class="Ledswitch.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:Ledswitch"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">

    <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
        <Button x:Name="On" Content="On" HorizontalAlignment="Left"
Margin="149,70,0,0" VerticalAlignment="Top" Click="On_Click"/>
        <Button x:Name="button" Content="Off" HorizontalAlignment="Left"
Margin="149,154,0,0" VerticalAlignment="Top" Click="button_Click"/>

    </Grid>
</Page>

CS
-----------------------------------------

using System;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.Devices.Gpio;

namespace App1
{
 
    public sealed partial class MainPage : Page
    {
        GpioPin _pin;
        public MainPage()
        {
            this.InitializeComponent();
            var controller = GpioController.GetDefault();
            _pin = controller.OpenPin(4);
         
        }

        private void btnOn_Click(object sender, RoutedEventArgs e)
        {
            _pin.SetDriveMode(GpioPinDriveMode.Output);
            _pin.Write(GpioPinValue.High);
        }

        private void btnOff_Click(object sender, RoutedEventArgs e)
        {
            _pin.Write(GpioPinValue.Low);
        }
    }
}

Develop an android Application that performs the following to promote the Swachhata Abhiyan in Surat 1) User type : End User a) Give facility of registration to citizen who are willing to join the Swachhata Abhiyan b) Login facility to registered user only c) Allow user to modify the details when they successfully logged in 2) User type : Official a) Login b) List the registered people in listview areawise

Develop an android Application that performs the
following to promote the Swachhata Abhiyan in Surat
1) User type : End User
     a) Give facility of registration to citizen who are
willing to join the Swachhata Abhiyan
     b) Login facility to registered user only
     c) Allow user to modify the details when
they successfully logged in
2) User type : Official
     a) Login
     b) List the registered people in listview areawise

--------------------------------------------------------------------------------------------------------------------------

--------------------------------------------------------------------------------------------
AndroidManifest.xml
-----------------------------
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.ouhvs.que14">

    <uses-permission android:name=
"android.permission.INTERNET" />

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name=".euser" />
        <activity android:name=".official" />
        <activity android:name=".userdetail" />
        <activity android:name=".register" />
        <activity android:name=".uedit" />
        <activity android:name=".display">

        </activity>
    </application>

</manifest>

------------------------
activity_main.xml
------------------------
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="com.example.ouhvs.que14.MainActivity">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textSize="30sp"
        android:text="Swachhata Abhiyan App"
        android:id="@+id/textView" />

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="End User"
        android:textSize="20sp"
        android:id="@+id/button"
        android:layout_below="@+id/textView"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="350dp" />

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Official User"
        android:textSize="20sp"
        android:id="@+id/button2"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true" />

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/imageView"
        android:layout_below="@+id/textView"
        android:layout_centerHorizontal="true"
        android:src="@drawable/img1" />
</RelativeLayout>

-----------------------
MainActivity.java
-----------------------
package com.example.ouhvs.que14;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class MainActivity extends AppCompatActivity {
    Button user,official;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        user=(Button)findViewById(R.id.button);
        official=(Button)findViewById(R.id.button2);

        user.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent i=new Intent(MainActivity.this,euser.class);
                startActivity(i);
            }
        });

        official.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent i=new Intent(MainActivity.this,official.class);
                startActivity(i);
            }
        });
    }
}

---------------------------
activity_official.xml
---------------------------
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="com.example.ouhvs.que14.official">

    <EditText
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/editText"
        android:hint="Enter username : "
        android:textSize="20sp"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="102dp" />

    <EditText
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/editText2"
        android:hint="Enter password : "
        android:textSize="20sp"
        android:inputType="textPassword"
        android:layout_centerVertical="true"
        android:layout_centerHorizontal="true" />

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Login"
        android:textSize="20sp"
        android:id="@+id/button3"
        android:layout_below="@+id/editText2"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="69dp" />

</RelativeLayout>

----------------
official.java
----------------
package com.example.ouhvs.que14;

import android.app.MediaRouteActionProvider;
import android.content.Intent;
import android.support.annotation.MainThread;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import com.android.volley.AuthFailureError;
import com.android.volley.Request;
import com.android.volley.RequestQueue;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.StringRequest;
import com.android.volley.toolbox.Volley;

import org.json.JSONObject;

import java.util.HashMap;
import java.util.Map;

public class official extends AppCompatActivity {
    EditText name,pass1;
    Button login;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_official);

        name=(EditText)findViewById(R.id.editText);
        pass1=(EditText)findViewById(R.id.editText2);

        login=(Button)findViewById(R.id.button3);

        login.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                StringRequest sr=new StringRequest(Request.Method.POST,
"http://10.0.2.2:7080/android/login.php",
new Response.Listener<String>() {
                    @Override
                    public void onResponse(String response) {
                        try
                        {
                            JSONObject jobj=new JSONObject(response);
                            if(jobj.getInt("success")==1)
                            {
                                Toast.makeText(official.this, jobj.getString("msg").
toString(), Toast.LENGTH_SHORT).show();
                                Intent i=new Intent(official.this,display.class);
                                startActivity(i);
                            }
                            else if(jobj.getInt("success")==0)
                            {
                                Toast.makeText(official.this, jobj.getString("msg").
toString(), Toast.LENGTH_SHORT).show();
                            }
                        }catch (Exception e)
                        {
                            Toast.makeText(official.this, e.getMessage(),
Toast.LENGTH_SHORT).show();
                        }
                    }
                }, new Response.ErrorListener() {
                    @Override
                    public void onErrorResponse(VolleyError error) {
                        Toast.makeText(official.this, error.getMessage(),
Toast.LENGTH_SHORT).show();
                    }
                }){
                    @Override
                    protected Map<String, String> getParams() throws AuthFailureError {
                        Map<String,String> param=new HashMap<String, String>();
                        param.put("uname",name.getText().toString());
                        param.put("pass",pass1.getText().toString());
                        return param;
                    }
                };
                RequestQueue rq= Volley.newRequestQueue(official.this);
                rq.add(sr);
            }
        });
    }
}

----------------
listview.xml
----------------
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <TableLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">
        <TableRow>
            <TextView
                android:id="@+id/row1"
                android:textSize="15sp"
                android:width="50sp"/>
        </TableRow>
    </TableLayout>
</LinearLayout>

---------------------------
activity_display.xml
---------------------------
<?xml version="1.0" encoding="utf-8"?>
<TableLayout 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:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="com.example.ouhvs.que14.display">
        <TableRow>

                <TextView
                    android:layout_width="150sp"
                    android:layout_height="wrap_content"
                    android:text="Select area : "
                    android:textSize="20sp"
                    android:id="@+id/textView3"
                    android:layout_column="0" />

                <Spinner
                    android:layout_width="200sp"
                    android:layout_height="wrap_content"
                    android:id="@+id/spinner"
                    android:layout_column="1" />
        </TableRow>
        <ListView android:id="@+id/listView"
            android:layout_column="12" />
</TableLayout>

----------------
display.java
----------------
package com.example.ouhvs.que14;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Spinner;
import android.widget.Toast;

import com.android.volley.AuthFailureError;
import com.android.volley.Request;
import com.android.volley.RequestQueue;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.StringRequest;
import com.android.volley.toolbox.Volley;

import org.json.JSONArray;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

public class display extends AppCompatActivity {
    ListView lv;
    ArrayList<String> alist,info;
    ArrayAdapter<String> ad;
    Spinner sp;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_display);

        lv=(ListView)findViewById(R.id.listView);
        sp=(Spinner)findViewById(R.id.spinner);
        alist=new ArrayList();
        info=new ArrayList();
        StringRequest sr=new StringRequest(Request.Method.POST,
"http://10.0.2.2:7080/android/area.php",
new Response.Listener<String>() {
            @Override
            public void onResponse(String response) {
                try {
                    JSONObject jobj = new JSONObject(response);
                    if(jobj.getInt("success")==1)
                    {
                        JSONArray area=jobj.getJSONArray("areas");
                        for(int i=0;i<area.length();i++)
                        {
                            JSONObject obj=area.getJSONObject(i);
                            alist.add(obj.getString("area"));
                        }
                        ad=new ArrayAdapter<String>(display.this,
android.R.layout.simple_list_item_1,alist);
                        sp.setAdapter(ad);
                    }
                    else {
                        Toast.makeText(display.this, "Couldnt fetch data",
Toast.LENGTH_SHORT).show();
                    }
                }catch (Exception e)
                {
                    Toast.makeText(display.this, "Problem : "+e.getMessage(),
Toast.LENGTH_SHORT).show();
                }
            }
        }, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError error) {
                Toast.makeText(display.this, "Error : "+error.getMessage(),
Toast.LENGTH_SHORT).show();
            }
        })
        {

        };
        RequestQueue rq= Volley.newRequestQueue(display.this);
        rq.add(sr);

        sp.setOnItemSelectedListener(new AdapterView.
OnItemSelectedListener() {
            @Override
            public void onItemSelected(AdapterView<?> parent,
View view, int position, long id) {
                String str=alist.get(position);
                loaddata(str);
            }

            @Override
            public void onNothingSelected(AdapterView<?> parent) {

            }
        });
    }

    public void loaddata(final String str){
        StringRequest sr=new StringRequest(Request.Method.POST,
"http://10.0.2.2:7080/android/display.php",
new Response.Listener<String>() {
            @Override
            public void onResponse(String response) {
                try
                {
                    JSONObject jobj=new JSONObject(response);
                    if(jobj.getInt("success")==1)
                    {
                        info.clear();
                        JSONArray jarr=jobj.getJSONArray("data");
                        for(int i=0;i<jarr.length();i++) {
                            JSONObject j = jarr.getJSONObject(i);
                            String str = j.getString("uname").toString() + "    " +
j.getString("mno");
                            info.add(str);
                        }
                        lv.setAdapter(new ArrayAdapter<String>(display.this,
android.R.layout.simple_list_item_1,info));
                    }
                    else
                    {
                        Toast.makeText(display.this, "Problem loading data",
Toast.LENGTH_SHORT).show();
                    }
                }catch (Exception e){
                    Toast.makeText(display.this, "Error : "+e.getMessage(),
Toast.LENGTH_SHORT).show();
                }
            }
        }, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError error) {

            }
        }){
            @Override
            protected Map<String, String> getParams() throws AuthFailureError {
                Map<String,String> param=new HashMap<String, String>();
                param.put("area",str);
                return param;
            }
        };
        RequestQueue rq=Volley.newRequestQueue(display.this);
        rq.add(sr);

    }
}

-------------------------
activity_euser.xml
-------------------------
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="com.example.ouhvs.que14.euser">

    <EditText
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/editText3"
        android:hint="Enter username : "
        android:textSize="20sp"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="71dp" />

    <EditText
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/editText4"
        android:hint="Enter password : "
        android:inputType="textPassword"
        android:textSize="20sp"
        android:layout_below="@+id/editText3"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="50dp" />

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Login"
        android:textSize="20sp"
        android:id="@+id/button4"
        android:layout_below="@+id/editText4"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="71dp" />

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Register"
        android:textSize="20sp"
        android:id="@+id/button5"
        android:layout_below="@+id/button4"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="44dp" />
</RelativeLayout>

---------------
euser.java
---------------
package com.example.ouhvs.que14;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import com.android.volley.AuthFailureError;
import com.android.volley.Request;
import com.android.volley.RequestQueue;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.StringRequest;
import com.android.volley.toolbox.Volley;

import org.json.JSONObject;

import java.util.HashMap;
import java.util.Map;

public class euser extends AppCompatActivity {
    Button login,register;
    EditText uname,pass;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_euser);

        login=(Button)findViewById(R.id.button4);
        register=(Button)findViewById(R.id.button5);
        uname=(EditText)findViewById(R.id.editText3);
        pass=(EditText)findViewById(R.id.editText4);

        login.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                StringRequest sr=new StringRequest(Request.Method.POST,
"http://10.0.2.2:7080/android/elogin.php",
new Response.Listener<String>() {
                    @Override
                    public void onResponse(String response) {
                        try
                        {
                            JSONObject jobj=new JSONObject(response);
                            if(jobj.getInt("success")==1)
                            {
                                Toast.makeText(euser.this, jobj.getString("msg"),
Toast.LENGTH_SHORT).show();
                                Intent i=new Intent(euser.this,uedit.class);
                                i.putExtra("uname",uname.getText().toString());
                                i.putExtra("pass",pass.getText().toString());
                                i.putExtra("id",jobj.getString("id1"));

                                startActivity(i);

                            }
                            else if(jobj.getInt("success")==0)
                            {
                                Toast.makeText(euser.this, jobj.getString("msg"),
Toast.LENGTH_SHORT).show();
                            }
                        }catch (Exception e)
                        {
                            Toast.makeText(euser.this, "Error "+e.getMessage(),
Toast.LENGTH_SHORT).show();
                        }
                    }
                }, new Response.ErrorListener() {
                    @Override
                    public void onErrorResponse(VolleyError error) {
                        Toast.makeText(euser.this, "Problem "+error.getMessage(),
Toast.LENGTH_SHORT).show();
                    }
                })
                {
                    @Override
                    protected Map<String, String> getParams() throws AuthFailureError {
                        Map<String,String> param=new HashMap<String, String>();
                        param.put("uname",uname.getText().toString());
                        param.put("pass",pass.getText().toString());
                        return param;
                    }
                };
                RequestQueue rq= Volley.newRequestQueue(euser.this);
                rq.add(sr);
            }
        });

        register.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent i=new Intent(euser.this,register.class);
                startActivity(i);
            }
        });
    }
}

----------------------------
activity_register.xml
----------------------------
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="com.example.ouhvs.que14.register">

    <EditText
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/editText5"
        android:hint="Enter username : "
        android:textSize="20sp"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="48dp" />

    <EditText
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:inputType="textPassword"
        android:textSize="20sp"
        android:hint="Enter password : "
        android:ems="10"
        android:id="@+id/editText6"
        android:layout_below="@+id/editText5"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="48dp" />

    <EditText
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/editText7"
        android:hint="Enter area : "
        android:textSize="20sp"
        android:layout_centerVertical="true"
        android:layout_centerHorizontal="true" />

    <EditText
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:inputType="number"
        android:hint="Enter mobile no. : "
        android:textSize="20sp"
        android:ems="10"
        android:id="@+id/editText8"
        android:layout_below="@+id/editText7"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="52dp" />

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Register"
        android:textSize="20sp"
        android:id="@+id/button6"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true" />
</RelativeLayout>

------------------
register.java
------------------
package com.example.ouhvs.que14;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import com.android.volley.AuthFailureError;
import com.android.volley.Request;
import com.android.volley.RequestQueue;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.StringRequest;
import com.android.volley.toolbox.Volley;

import org.json.JSONObject;

import java.util.HashMap;
import java.util.Map;

public class register extends AppCompatActivity {
    EditText uname,pass,area,mno;
    Button register;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_register);

        uname=(EditText)findViewById(R.id.editText5);
        pass=(EditText)findViewById(R.id.editText6);
        area=(EditText)findViewById(R.id.editText7);
        mno=(EditText)findViewById(R.id.editText8);

        register=(Button)findViewById(R.id.button6);

        register.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                StringRequest sr=new StringRequest(Request.Method.POST,
"http://10.0.2.2:7080/android/register.php",
new Response.Listener<String>() {
                    @Override
                    public void onResponse(String response) {
                        try {
                            JSONObject jobj = new JSONObject(response);
                            if(jobj.getInt("success")==1)
                            {
                                Toast.makeText(register.this, "User registered
successfully", Toast.LENGTH_LONG).show();
                            }
                            else if(jobj.getInt("success")==0)
                            {
                                Toast.makeText(register.this, "Invalid data.
please enter correct data", Toast.LENGTH_LONG).show();
                            }
                        }
                        catch (Exception e)
                        {
                            Toast.makeText(register.this, e.getMessage(),
Toast.LENGTH_SHORT).show();
                        }
                    }
                }, new Response.ErrorListener() {
                    @Override
                    public void onErrorResponse(VolleyError error) {
                        Toast.makeText(register.this, error.getMessage(),
Toast.LENGTH_SHORT).show();
                    }
                })
                {
                    @Override
                    protected Map<String, String> getParams() throws AuthFailureError {
                        Map<String,String> param =new HashMap<String, String>();
                        param.put("uname",uname.getText().toString());
                        param.put("pass",pass.getText().toString());
                        param.put("area",area.getText().toString());
                        param.put("mno",mno.getText().toString());
                        return param;
                    }
                };
                RequestQueue rq=Volley.newRequestQueue(register.this);
                rq.add(sr);
            }
        });
    }
}

------------------------
activity_uedit.xml
------------------------
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="com.example.ouhvs.que14.uedit">

    <EditText
        android:layout_width="210sp"
        android:layout_height="wrap_content"
        android:id="@+id/editText9"
        android:textSize="20sp"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="75dp"
        android:visibility="visible" />

    <EditText
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:inputType="textPassword"
        android:hint="Enter password"
        android:ems="10"
        android:id="@+id/editText10"
        android:layout_below="@+id/editText9"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="42dp" />

    <EditText
        android:layout_width="210sp"
        android:layout_height="wrap_content"
        android:id="@+id/editText11"
        android:textSize="20sp"
        android:layout_below="@+id/editText10"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="54dp" />

    <EditText
        android:layout_width="210sp"
        android:layout_height="wrap_content"
        android:id="@+id/editText12"
        android:textSize="20sp"
        android:layout_below="@+id/editText11"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="42dp" />

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Update"
        android:textSize="20sp"
        android:id="@+id/button7"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true" />

    <TextView
        android:layout_width="100sp"
        android:layout_height="wrap_content"
        android:text=""
        android:textSize="20sp"
        android:id="@+id/textView2"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:visibility="invisible"
        android:enabled="false" />
</RelativeLayout>

-------------
uedit.java
-------------
package com.example.ouhvs.que14;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

import com.android.volley.AuthFailureError;
import com.android.volley.Request;
import com.android.volley.RequestQueue;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.StringRequest;
import com.android.volley.toolbox.Volley;

import org.json.JSONObject;

import java.util.HashMap;
import java.util.Map;

public class uedit extends AppCompatActivity {
    TextView id;
    EditText uname,pass,area,mno;
    String uname1,pass1,id1;
    Button update;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_uedit);

        Intent i=getIntent();
        uname1=i.getStringExtra("uname");
        pass1=i.getStringExtra("pass");
        id1=i.getStringExtra("id");
        id=(TextView)findViewById(R.id.textView2);
        uname=(EditText)findViewById(R.id.editText9);
        pass=(EditText)findViewById(R.id.editText10);
        area=(EditText)findViewById(R.id.editText11);
        mno=(EditText)findViewById(R.id.editText12);
        update=(Button)findViewById(R.id.button7);

        StringRequest sr=new StringRequest(Request.Method.POST,
"http://10.0.2.2:7080/android/fetchdata.php",
new Response.Listener<String>() {
            @Override
            public void onResponse(String response) {
                try
                {
                    JSONObject jobj=new JSONObject(response);

                    id.setText(jobj.getString("id"));
                    uname.setText(jobj.getString("uname"));
                    pass.setText(jobj.getString("password"));
                    area.setText(jobj.getString("area"));
                    mno.setText(jobj.getString("mno"));
                }catch (Exception e){
                    Toast.makeText(uedit.this, "Problem "+e.getMessage(),
Toast.LENGTH_LONG).show();
                }
            }
        }, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError error) {
                Toast.makeText(uedit.this, "Error "+error.getMessage(),
Toast.LENGTH_SHORT).show();
            }
        }){
            @Override
            protected Map<String, String> getParams() throws AuthFailureError {
                Map<String,String> param=new HashMap<String, String>();
                param.put("uname",uname1);
                param.put("pass",pass1);
                param.put("id",id1);
                return param;
            }
        };
        RequestQueue rq= Volley.newRequestQueue(uedit.this);
        rq.add(sr);

        update.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                StringRequest sr=new StringRequest(Request.Method.POST,
"http://10.0.2.2:7080/android/eupdate.php",
new Response.Listener<String>() {
                    @Override
                    public void onResponse(String response) {
                        try
                        {
                            JSONObject jobj=new JSONObject(response);
                            if(jobj.getInt("success")==1)
                            {
                                Toast.makeText(uedit.this, "Data updated successfully",
Toast.LENGTH_SHORT).show();
                            }
                            else if(jobj.getInt("success")==0)
                            {
                                Toast.makeText(uedit.this, "Data could'nt be updated",
Toast.LENGTH_SHORT).show();
                            }
                        }catch (Exception e){
                            Toast.makeText(uedit.this, "Error "+e.getMessage(),
Toast.LENGTH_SHORT).show();
                        }
                    }
                }, new Response.ErrorListener() {
                    @Override
                    public void onErrorResponse(VolleyError error) {
                        Toast.makeText(uedit.this, error.getMessage(),
Toast.LENGTH_SHORT).show();
                    }
                }){
                    @Override
                    protected Map<String, String> getParams() throws AuthFailureError {
                        Map<String,String> param=new HashMap<String, String>();
                        param.put("id",id1);
                        param.put("uname",uname.getText().toString());
                        param.put("pass",pass.getText().toString());
                        param.put("area",area.getText().toString());
                        param.put("mno",mno.getText().toString());
                        return param;
                    }
                };
                RequestQueue rq=Volley.newRequestQueue(uedit.this);
                rq.add(sr);
            }
        });
    }
}

---------------------
Web Services
---------------------

---------------
elogin.php
---------------
<?php
$response=array();
$cnn=mysqli_connect("localhost","root","","android");
$uname=$_REQUEST['uname'];
$pass=$_REQUEST['pass'];

$qry=mysqli_query($cnn,"select uname,
password,id from euser where uname='$uname'
and password='$pass'");

if(mysqli_num_rows($qry)>0)
{
$response['success']=1;
$row1=mysqli_fetch_array($qry);
$response['msg']="User is valid";
$response['id1']=$row1['id'];
}
else
{
$response['success']=0;
$response['msg']="Invalid username or password";
}

echo json_encode($response);
?>

-------------
login.php
-------------
<?php

$response=array();
$cnn=mysqli_connect("localhost","root","","android");
$uname=$_REQUEST['uname'];
$pass=$_REQUEST['pass'];

$qry=mysqli_query($cnn,"select username,
password from official where username='$uname'
and password='$pass'");

if(mysqli_num_rows($qry)>0)
{
$response['success']=1;
$response['msg']="User is valid";
}
else
{
$response['success']=0;
$response['msg']="Invalid username or password";
}

echo json_encode($response);

?>

-----------------
register.php
-----------------
<?php

$response=array();
$cnn=mysqli_connect("localhost","root","","android");

$uname=$_REQUEST['uname'];
$pass=$_REQUEST['pass'];
$area=$_REQUEST['area'];
$mno=$_REQUEST['mno'];
if($uname!="" && $pass!="" && $area!="" && $mno!="")
{
$qry=mysqli_query($cnn,"INSERT INTO
`euser`(`uname`, `password`, `area`, `mobile`)
VALUES ('$uname','$pass','$area','$mno')");

if($qry)
{
$response['success']=1;
}
else
{
$response['success']=0;
}
}
else
{
$response['success']=0;
}
echo json_encode($response);
?>

-------------------
fetchdata.php
-------------------
<?php
$response=array();
$cnn=mysqli_connect("localhost","root","","android");
$uname=$_REQUEST['uname'];
$pass=$_REQUEST['pass'];
$id=$_REQUEST['id'];


$query=mysqli_query($cnn,"select * from euser where id='$id'");
if(mysqli_num_rows($query)>0)
{
$row=mysqli_fetch_array($query);
$response['id']=$row['id'];
$response['uname']=$row['uname'];
$response['password']=$row['password'];
$response['area']=$row['area'];
$response['mno']=$row['mobile'];
}


echo json_encode($response);
?>

------------------
eupdate.php
------------------
<?php
$response=array();
$cnn=mysqli_connect("localhost","root","","android");

$id=$_REQUEST['id'];
$uname=$_REQUEST['uname'];
$pass=$_REQUEST['pass'];
$area=$_REQUEST['area'];
$mno=$_REQUEST['mno'];

if($id!="" && $uname!="" && $pass!="" && $area!="" && $mno!="")
{
$qry=mysqli_query($cnn,"UPDATE `euser`
SET `uname`='$uname',`password`='$pass',`area`='$area',
`mobile`='$mno' WHERE `id`='$id'");

if($qry)
{
$response['success']=1;
}
else
{
$response['success']=0;
}
}
else
{
$response['success']=0;
}
echo json_encode($response);
?>

-------------
area.php
-------------
<?php
$response=array();
$cnn=mysqli_connect("localhost","root","","android");
$qry=mysqli_query($cnn,"SELECT
distinct(`area`) FROM `euser` ORDER BY `area`");
$response['areas']=array();
if(mysqli_num_rows($qry)>0)
{
while($row=mysqli_fetch_array($qry))
{
$a=array();
$a['area']=$row['area'];
array_push($response['areas'],$a);
}
$response['success']=1;
}
else
{
$response['success']=0;
}
echo json_encode($response);
?>

----------------
display.php
----------------
<?php

$response=array();
$cnn=mysqli_connect("localhost","root","","android");
$area=$_REQUEST['area'];
$result=mysqli_query($cnn,"SELECT `uname`,
`area`, `mobile` FROM `euser` where `area`='$area'");
$response['data']=array();
if(mysqli_num_rows($result)>0)
{
while($row=mysqli_fetch_array($result))
{
$data=array();
$data['uname']=$row['uname'];
$data['mno']=$row['mobile'];
array_push($response['data'],$data);
}
$response['success']=1;
}
else
{
$response['success']=0;
}
echo json_encode($response);

?>

Monday, August 3, 2015

PHP 7 Features

Since many years from now, PHP has been regarded as one of the truly brilliant server side scripting languages used for development of websites and web applications. There has a huge collection of PHP versions which have been successful in becoming the best choices of web developers all over the world. The next one to join the group of PHP is PHP 7. With its planned released date approaching at a rapid pace, there have been constant debates regarding the features that would be available with this yet another PHP software version.

PHP 7 Features that will woo every PHP fan

In this post, I’ll be focusing my attention of some of the features that are expected to arrive with the yet-to-be-released PHP version 7. I’m sure a detailed knowledge about these features would allow you to make the most of PHP for your good. So, let’s learn more about these PHP 7 features.

The problem of Return Types would come to an end
With the release of PHP 7, you’ll now be able to indicate appropriate return types on functions in the form displayed below:

function foo(): array {

return [];

}
You can specify the return types as int, string, bool etc. The only thing that you need to remember here is hat all you methods and functions which would be returning a specific return type would be unsigned. A possible solution to this is to return instances of wrappers for such kind of values.

The all-new Combined Comparison Operator
Also known as the spaceship operator, the Combined Comparison Operator <=> serves as a brilliant addition to PHP. It works just like strcmp() or the version_compare() functions returning -1 in case the left operand is smaller than the right one, 1 in case the left is greater than the right one and 0 in case both are equal. One of the greatest advantages of Combined Comparison operator is that it can be conveniently used any two operands(floats, integers, arrays etc.) and not just the strings. Have a look at how the Combined Comparison Operator is used in sorting callbacks:

// Pre Spacefaring^W PHP 7

function order_func($x, $y) {

return ($x < $y) ? -1 : (($x > $y) ? 1 : 0);

}



// Post PHP 7

function order_func($x, $y) {

return $x <=> $y;

}
Commendable performance improvements
With key changes being introduced as phpng, PHP 7 will have its performance raised by great bounds and leaps. A majority of smaller hosts would benefit from this increased performance and adopt PHP 7 without giving a second thought. It is expected that PHP 7 will have its performance at par with Facebook HHVM. The only exception being that PHP 7 won’t have a JIT(Just In Time) compiler. Additionally, this new PHP version would also have substantial memory savings.

Changes in terms of Extension APIs
Although the API used for building PHP extensions is still under the refurbishing process, it is subjected to multiple changes. The all new extension API introduced with PHP 7 would be compatible with HHVM run-time as well.

Addition of Abstract Syntax Tree(AST)
As an attempt to bring in the must-needed userland consistency, the PHP web development community has planned to add Abstract Syntax Tree(AST) into the PHP version 7. Serving as an intermediate code representation tool, AST would allow you to eliminate some of the visible inconsistencies in addition to creating room for incredible tooling such as the usage of AST for creating absolutely stunning opcodes.

Introduction of Uniform Variable Syntax
Uniform Variable Syntax plays a pivotal role in solving multiple inconsistencies in the way different expressions are being evaluated. For instance, here is how you can call closures which are already assigned to properties with the help of


$object->closureProperty) ():

class foo { static $bar = 'woo'; }

class woo { static $bat = 'Features of PHP7'; }

woo::$bat = function () { echo "Features of PHP7"; };

$exp = 'foo';

($exp::$bar::$bat)();
To be more precise, before PHP 7 was being talked about, $obj->$properties[ ‘name’] was used for accessing property which had its name available within the name key of $properties array. Now, with the Universal Variable Syntax, the same would access the name key of the property which has its name housed inside $properties.

That’s it for now!

Conclusion

There’s no doubt that PHP 7 is assumed to be one of the most promising versions of PHP. Now that you know about some of the most impressive features that it has in store for you, it’s time to wait for the ‘Big’ release and take full advantage of PHP for flawless web development.

Saturday, June 27, 2015

Why Codeigniter Framework is Better than Custom or Core PHP Development?

CodeIgniter is one of the most popular PHP frameworks around. It uses the Model-View-Controller Architectural design pattern and it’s considered by lots of PHP developers as one of the best framework solution for small to medium projects. It has some great features that we are going to talk about them in this article.

Why use a framework ?

“Frameworks make my life easier.” said most of the programmers asked this question.

In order to make a good, cleanly coded, reliable, high performance, fast and maintainable application you need to do a lot of analysis and intensive software engineering and architectural design tasks first. Luckily, lots of those tasks will be previously done by a framework so you can focus on the development of your application.

Most of PHP frameworks available support the MVC pattern, good file organization, have loads of utilities and libraries, are well secured, have performance abilities e.g. caching and benchmarking and much more awesome capabilities. CodeIgniter has the mentioned features and more that we will talk about now.

MVC pattern

CodeIgniter uses Model-View-Controller pattern which is the most used architectural design pattern in web application. It can also be turned into supporting the more advanced Hierarchical Model View Controller(HMVC) pattern by installing the popular CodeIgniter HMVC Extension.

Awesome Documentation

It’s true that bad documentation can ruin a good product. But CodeIgniter has a great a well detailed documentation files that takes you from the first steps of knowing the basics about the framework to a full reference for each class, helper & driver with simple examples provided.

Community

While being stuck at something with CodeIgniter and didn’t find the answer in the documentation, just don’t panic. There is a developers’ community full of CI gurus who are always willing to help. You may even find that your question has been answered before.

Performance

Since performance has been a major concern for each web developer, CodeIgniter is optimized to boost you code performance. In addition, it contains a beautiful caching class that you should check and use.

Helpers

CodeIgniter contains wide variety of helper functions that were created to help you write cleaner code and save time and effort doing repetitive tasks. For example, there is form, form validation, array, path, security and more that you can check at the documentation part of CodeIgniter’s documentation section of the official website.

Thursday, April 30, 2015

Why does my website need SEO?

The majority of web traffic is driven by the major commercial search engines, Google, Bing, and Yahoo!. Although social media and other types of traffic can generate visits to your website, search engines are the primary method of navigation for most Internet users. This is true whether your site provides content, services, products, information, or just about anything else.

Search engines are unique in that they provide targeted traffic—people looking for what you offer. Search engines are the roadways that make this happen. If search engines cannot find your site, or add your content to their databases, you miss out on incredible opportunities to drive traffic to your site.

Search queries—the words that users type into the search box—carry extraordinary value. Experience has shown that search engine traffic can make (or break) an organization's success. Targeted traffic to a website can provide publicity, revenue, and exposure like no other channel of marketing. Investing in SEO can have an exceptional rate of return compared to other types of marketing and promotion.

Tuesday, April 28, 2015

What is SEO?

SEO stands for “search engine optimization.” It is the process of getting traffic from the “free,” “organic,” “editorial” or “natural” search results on search engines.

SEO is the practice of improving and promoting a website to increase the number of visitors the site receives from search engines. There are many aspects to SEO, from the words on your page to the way other sites link to you on the web. Sometimes SEO is simply a matter of making sure your site is structured in a way that search engines understand.
SEO isn't just about building search engine-friendly websites. It's about making your site better for people too. At Moz we believe these principles go hand-in-hand.
This guide is designed to describe all areas of SEO—from finding the terms and phrases (keywords) that generate traffic to your website, to making your site friendly to search engines, to building links and marketing the unique value of your site. If you are confused about this stuff, you are not alone, and we're here to help.

Monday, April 27, 2015

What is a Website?

One of the most common reasons for us to be hanging around on the Internet every day is the abundance of information it is loaded with. The information is generated by multiple sources and is carefully organized in the form of files and web pages, which, when grouped together to form a single entity, become a website