Social

Thursday, January 2, 2014

PHP Simple Contact Us Form


     In this post I’ll show how to design a contact us form using PHP language. And this can send the form details that the user types to any type of email.
     So first thing first. You needed to design the main page that contain the fields that you want to get from the user. And here my main page is main.html,
 <html>  
 <head>  
 <title>Cantact Us Form</title>  
 </head>  
 <body>  
 <form name='form' method='post' action="send_mail.php">  
      <input type="text" name="name" />  
      <input type="text" name="email"/>  
      <textarea name="msg" cols="85" rows="5" ></textarea>  
      <input type="submit" value="Submit" name="submit_email" />  
 </form>  
 </body>  
 </html>  

Wednesday, January 1, 2014

SQLite Android JAVA Tutorial 04 – Update DB & Delete from DB



Update DB :

Following Java code shows how we can use UPDATE statement to update any record from our table test_table,

public class Sqlite_Tute extends Activity {
      
       SQLiteDatabase db;

       @Override
       protected void onCreate(Bundle savedInstanceState) {
              // TODO Auto-generated method stub
              super.onCreate(savedInstanceState);
              requestWindowFeature(Window.FEATURE_NO_TITLE);
              setContentView(R.layout.sqlite_tute);
             
             
              try
              {
                     db = openOrCreateDatabase("testDB", MODE_PRIVATE,null);
                     db.execSQL("CREATE TABLE IF NOT EXISTS test_table (_id INTEGER PRIMARY KEY AUTOINCREMENT,_name TEXT,_email TEXT,_age INTEGER);");
              }
              catch(Exception e)
              {
                     Log.d("rockman", "DB Creation or TABLE Creation ERROR--"+e.toString());
              }

              /////////////////////////// UPDATE PART

String email = ”test123@test.com”; //new value
int age = 34; //new value

              try
              {
                     ContentValues values = new ContentValues();

                     values.put("_email", email);
                     values.put("_age", age);
      
                     db.update("test_table", values, "id=15", null);
}
              catch(Exception e)
              {
                     Log.d("rockman", "UPDATE ERROR--"+e.toString());
              }

       }
}

SQLite Android JAVA Tutorial 03 – Insert into DB & Select from DB



Insert into DB :

Let’s say we need to insert a raw of data now. The following Java program shows how we can insert records in our test_table created in previous post.

public class Sqlite_Tute extends Activity {
      
       SQLiteDatabase db;

       @Override
       protected void onCreate(Bundle savedInstanceState) {
              // TODO Auto-generated method stub
              super.onCreate(savedInstanceState);
              requestWindowFeature(Window.FEATURE_NO_TITLE);
              setContentView(R.layout.sqlite_tute);
             
             
              try
              {
                     db = openOrCreateDatabase("testDB", MODE_PRIVATE,null);
                     db.execSQL("CREATE TABLE IF NOT EXISTS test_table (_id INTEGER PRIMARY KEY AUTOINCREMENT,_name TEXT,_email TEXT,_age INTEGER);");
              }
              catch(Exception e)
              {
                     Log.d("rockman", "DB Creation or TABLE Creation ERROR--"+e.toString());
              }

              /////////////////////////// INSERT PART
String name = ”Rockman”;
String email = ”test@test.com”;
int age = 24;

              try
              {
                     ContentValues values = new ContentValues();

                     values.put("_name", name);
                     values.put("_email", email);
                     values.put("_age", age);
      
                     db.insert("test_table", null, values);         
}
              catch(Exception e)
              {
                     Log.d("rockman", "INSERT ERROR--"+e.toString());
              }

       }
}

SQLite Android JAVA Tutorial 02 – Connecting to DB & Create a table


Connecting to DB :
First you need to import android.database.sqlite.SQLiteDatabase,

import android.database.sqlite.SQLiteDatabase;

Now within the main class create a variable using SQLiteDatabase class. Using that variable we are going to do create OR open a database called “testDB”. If the “testDB” is previously created then it will open. And if the “testDB” not found the it will be created and open it.
The following JAVA program shows how to do that.

public class Sqlite_Tute extends Activity {
      
       SQLiteDatabase db;

       @Override
       protected void onCreate(Bundle savedInstanceState) {
              // TODO Auto-generated method stub
              super.onCreate(savedInstanceState);
              requestWindowFeature(Window.FEATURE_NO_TITLE);
              setContentView(R.layout.sqlite_tute);
             
             
              try
              {
                     db = openOrCreateDatabase("testDB", MODE_PRIVATE,null);                            }
              catch(Exception e)
              {
                     Log.d("rockman", "DB Creation ERROR--"+e.toString());
              }
       }
}


 

Search This Blog

Most Reading

Protected by Copyscape Duplicate Content Software

Facebook Page