Saturday, April 25, 2015

ANDROID WITH PHP CONNECTION

PHP CODINGS:-

<?php 

$query=mysql_connect("localhost","root","");
mysql_select_db("androidcalldb",$query);
extract($_GET);

if(isset($s1))
{
echo "GANESH";

$que=mysql_query("select max(id) as maxid from datainsert") or die("ERROR IN ID CONNECTION");
$res=mysql_fetch_array($que);
$id=$res['maxid']+1;


$query1=mysql_query("insert into datainsert(id,fname,sname)values('$id','$fname','$sname')") or die("Error in connection");
if($query1)
{
echo "succesfully submitted";

}
else
{
 echo "not submitted";

 }

}




?>


------------------------------------------------------------------------------------------------------------------------
PHP URL:
http://localhost/androidcall.php?fname=Ragaven&sname=Ganesan&s1=Submit
------------------------------------------------------------------------------------------------------------------------
ANDROID CODING:

package php.call;

import java.net.HttpURLConnection;
import java.net.URL;
import java.io.DataInputStream;

import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;

public class MainActivity extends ActionBarActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
public void sub1(View v)
{
try
{

EditText e1=(EditText)findViewById(R.id.editText1);
EditText e2=(EditText)findViewById(R.id.editText2);
String fname=e1.getText().toString();
String sname=e2.getText().toString();

String ur="http://14.96.39.125/androidcall.php?fname="+fname.trim()+"&sname="+sname.trim()+"&s1=Submit";
ur=ur.replace("+", "%2B");
Log.i("Register",ur);
URL url=new URL(ur);
HttpURLConnection uc= (HttpURLConnection)url.openConnection();
DataInputStream dis= new DataInputStream(uc.getInputStream());
String t = "";String txt="";
while((t=dis.readLine()) !=null)
{
txt += t;
}
Log.i("LoginResult",txt);
Toast.makeText(getApplicationContext(), txt, Toast.LENGTH_LONG).show();
dis.close();



  }

catch(Exception e)
{
Log.i("Store ",e.getMessage());

}




}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
--------------------------------------------------------------------------------------------------------------------------
ANDROID FRONT END

PHP WAMP SERVER BACK END


Wednesday, December 24, 2014

SIMPLE DATABASE CONNECTIVITY PROGRAM IN PHP

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>PHP DATABSAE</title>
</head>

<body>
<?php

$query=mysql_connect("localhost","root","");
mysql_select_db("cloud",$query) ;
$name1=$_POST['firstname'];
$name2=$_POST['lastname'];
//echo "insert into register(firstname,secondname)values('$name','$name2')";
$query1=mysql_query("INSERT into register(firstname,secondname)values('$name1','$name2')");
if($query1)
{
 echo "succesfully submitted";
 }
 else
 {
 echo "please submit again";
 }

?>
</body>
</html>

Wednesday, December 17, 2014

TIMER APPLICATION code for 20 Minutes Alert using c#

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Timer
{
    public partial class Form1 : Form
    {

        int i = Convert.ToInt32(0);
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {

            label1.Text = DateTime.Now.ToString();
           

        }

        private void timer1_Tick(object sender, EventArgs e)
        {

            i++;
            if (i==20)
            {
                MessageBox.Show("20 minutes is left");
                i = 0;
            }

        }

Monday, July 7, 2014

AGE CALCULATOR

CurrentDate: BirthDate: Age:

Sunday, April 20, 2014

DECRYPTION IN UNIX C

DECRYPTION


[ragava@localhost ~]$ cat dc.c
#include<stdio.h>

main(int argc, char *argv[])
        {
                int i;
                char a[2000],b;
                FILE *fp;
                if(argc!=2)
                        {
                                printf("Usage error");
                                return;
                        }

                fp=fopen(argv[1],"r");
                if(fp==NULL)
                        {
                                printf("ERROR IN OPENING A FILE");
                                return;
                        }
                for(i=0,a[i]=getc(fp);feof(fp)!=0;a[++i]=getc(fp))
                                 ;
                a[i]='\0';
                fclose(fp);
                remove(argv[1]);
                fp=fopen(argv[1],"w");

                for(i=0;a[i]!='\0';i++)

                        {
                                b=a[i]-2;
                                putc(b,fp);
                        }
                fclose(fp);
        }

[ragava@localhost ~]$
 

ENCRYPTION IN UNIX C

ENCRYPTION

[ragava@localhost ~]$ cat ec.c
#include<stdio.h>

main(int argc, char *argv[])
        {
                int i;
                char a[2000],b;
                FILE *fp;
                if(argc!=2)
                        {
                                printf("Usage error");
                                return;
                        }

                fp=fopen(argv[1],"r");
                if(fp==NULL)
                        {
                                printf("ERROR IN OPENING A FILE");
                                return;
                        }
                for(i=0,a[i]=getc(fp);feof(fp)!=0;a[++i]=getc(fp))
                                 ;
                a[i]='\0';
                fclose(fp);
                remove(argv[1]);
                fp=fopen(argv[1],"w");

                for(i=0;a[i]!='\0';i++)

                        {
                                b=a[i]+2;
                                putc(b,fp);
                        }
                fclose(fp);
        }

 

SENDING MAIL THROUGH C#

SMTP MAIL IN C SHARP

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.Net.Mail;

namespace mailing
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            MailMessage message = new MailMessage();
            message.To.Add("ragava08@ymail.com");
            message.Subject = "SUBJECT";
            message.From = new MailAddress("ragava08@gmail.com");
            message.Body = "BODY PART";
            SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com");
            SmtpServer.Port = 587;
         SmtpServer.Credentials = new System.Net.NetworkCredential("ragava08@gmail.com", "password");
            SmtpServer.EnableSsl = true;
            SmtpServer.Send(message);
            MessageBox.Show("Message successfully sent");

        }
    }
}