Monday, 25 July 2016

Simple project to understand about register a user account , user login & admin login & admin managing user account

Simple project    to understand   about register a  user   account , user login  & admin login & admin managing user account:

Step 1:

Create  two table first userrecord for user and  adminlogin  for  admin:

Create table userrecord
(id  int primary key auto_increment,
namevarchar(200),
contactvarchar(200),
emailvarchar(200),
password  varchar(200)
);

Create table  adminlogin
(idint primary key auto_increment,
usernamevarchar(200),
passwordvarchar(200)
);

Step 2:
(a)write code for register.html:

<form action="register.php" method="post">
name<input type="text" name="name">
contact<input type="text" name="contact">
email<input type="text" name="email">
password<input type="password" name="password">
<input type="submit" name="submit" value="submit">
</form>



(b)write code for  register.php  :
<?php
$name=$_POST['name'];
$email=$_POST['email'];
$contact=$_POST['contact'];
$password=$_POST['password'];
$con=mysql_connect("localhost","root","");
mysql_select_db("simpleproject",$con);
$sql="select * from userrecord where email='$email'";
                $result=mysql_query($sql);
                $num=mysql_num_rows($result);
                if($num>0)
                {
                                echo "<font color=red>email id is already used please use another email id</font>";
                }
                else
                {
                                $sql1="insert into userrecord(name,email,contact,password) values('$name','$email','$contact','$password')";
                                mysql_query($sql1);
                                echo "<font color=red>successfully  registered </font>";
                }
?>


Step 3:

(a)write code for  userlogin.html:

<form action="userlogin.php" method="post">
email<input type="text" name="email">
password<input type="password" name="password">
<input type="submit" name="submit" value="submit">
</form>

(b)write code for    userlogin.php :

<?php
$con=mysql_connect("localhost","root","");
mysql_select_db("simpleproject",$con);
$email=$_POST['email'];
$password=$_POST['password'];
$sql="select email,password from userrecord where email='$email' and password='$password'";
$result=mysql_query($sql);
$num=mysql_num_rows($result);
if($num>0)
{
session_start();
$_SESSION['email']=$email;
header('location:userwelcome.php');
}
else
{
echo "invalid userlogin";
}
?>

( c) now write code for  userwelcome.php  :


<?php
session_start();
if(!isset($_SESSION['email']))
{
header("location:usererror.php");
}
echo "<h1>welcome</h1>";
echo '<a href="userlogout.php">userlogout</a>'.'<br>';

$email=$_SESSION['email'];

echo "welocme =".$email.'<br>';

//display code  for user record who made current login//

$con=mysql_connect("Localhost","root","");
mysql_select_db("simpleproject",$con);

$sql="select * from  userrecord  where email='$email'";

$result=mysql_query($sql);
while($row=mysql_fetch_array($result))

 {
 echo "<h1>user details </h1>";
  echo "ID=".$row['id'];

  echo '<br>';
   echo "NAME=".$row['name'];

   echo '<br>';
    echo "CONTACT=".$row['contact'];
 
    echo '<br>';
     echo "PASSWORD=".$row['password'];



 }


 echo '<a href="change_password.php">change password</a>'.'<br>';
 echo '<a href="change_profile.php">change profile</a>'.'<br>';

?>


output:




(d)now write code for  userlogout.php:

<?php

session_start();
session_destroy();
header('Location:userlogin.html');
?>
(e)write code for usererror.php:

<?php

echo "make login first";

echo '<a href="userlogin.html">login</a>';

?>

(f) Now write code for  change_password.php   file:
<?php
session_start();
if(!isset($_SESSION['email']))
{
header("location:usererror.php");
}
?>
<form action="final_change_password.php" method="post">
Enter New Password<input type="password" name="password">
<input type="submit" name="submit" value="change password">
</form>

(g)Now  write code  for  final_change_password.php  file:


<?php
session_start();
if(!isset($_SESSION['email']))
{
header("location:usererror.php");
}
?>
<?php
$email=$_SESSION['email'];

$con=mysql_connect("localhost","root","");
mysql_select_db("mandar",$con);



$password=$_POST["password"];


$sql="update userrecord set password='$password' where email='$email'";

$result=mysql_query($sql) or die (mysql_error());
if($result)
{
echo "record update successfully";
}
else
{
echo "record not updated";
}

?>


(h)write code for   change_profile.php    file:

<?php
session_start();
if(!isset($_SESSION['email']))
{
header("location:usererror.php");
}
?>


<?php

$email=$_SESSION['email'];

$con=mysql_connect("Localhost","root","");
mysql_select_db("simpleproject",$con);

$sql="select * from  userrecord  where email='$email'";

$result=mysql_query($sql);
while($row=mysql_fetch_array($result))

 {

echo '
<form action="final_change_profile.php" method="post">
name<input type="name"  name=name   value="'.$row['name'].'">
contact<input type="name" name=contact  value="'.$row['contact'].'">
<input type="submit" name="submit" value="update-profile">
</form>';

}


(i)write code for  final_change_profile.php   file:


<?php
session_start();
if(!isset($_SESSION['email']))
{
header("location:usererror.php");
}
?>




<?php
$email=$_SESSION['email'];

$con=mysql_connect("localhost","root","");
mysql_select_db("simpleproject",$con);



$name=$_POST["name"];
$contact=$_POST["contact"];


$sql="update userrecord set name='$name',contact='$contact' where email='$email'";

$result=mysql_query($sql) or die (mysql_error());
if($result)
{
echo "record update successfully";
}
else
{
echo "record not updated";
}

?>





Now start coding part for admin :


Step  1:

(a)write code for adminlogin.html:

<form action="adminlogin.php" method="post">
username<input type="text" name="username">
password<input type="password" name="password">
<input type="submit" name="submit" value="submit">
</form>


(b)now write code for adminlogin.php:

<?php
$con=mysql_connect("localhost","root","");
mysql_select_db("abhi",$con);
$username=$_POST['username'];
$password=$_POST['password'];
$sql="select username,password from adminlogin where username='$username' and password='$password'";
$result=mysql_query($sql);
$num=mysql_num_rows($result);
if($num>0)
{
session_start();
$_SESSION['username']=$username;
header('location:display.php');
}
else
{
echo "invalid login";
}
?>

(c )now write code for display.php :

<?php
session_start();
if(!isset($_SESSION['username']))
{
                header('location:adminerror.php');
               
}
?>

<a href="adminlogout.php">Logout</a>
<?php
$con=mysql_connect("localhost","root","");
mysql_select_db("abhi",$con);
$sql="select * from userrecord";
$result=mysql_query($sql);
echo '<table border=1><tr><td>id</td><td>name</td><td>email</td><td>password</td><td>&nbsp;</td><td>&nbsp;</td></td>';
while($row=mysql_fetch_array($result))
{
echo '<tr>';
echo '<td>';
echo $row['id'];
echo '</td>';
echo '<td>';
echo $row['name'];
echo '</td>';
echo '<td>';
echo $row['email'];
echo '</td>';
echo '<td>';
echo $row["password"];

echo '</td>';
echo '<td><form action="update.php" method="post">
<input type="hidden" name="hidden" value="'.$row['id'].'">
<input type="submit" name="button" value="update">
</form></td>';

echo '<td><form action="delete.php" method="post">
<input type="hidden" name="hidden" value="'.$row['id'].'">
<input type="submit" name="button" value="delete">
</form></td>';

echo '</tr>';

}
echo '</table>';

?>

(d)now write code for  update.php   file:           
           
<?php
session_start();
if(!isset($_SESSION['username']))
{
   header('location:adminerror.php');
                                                                                                       
}
?>

<?php
$hidden=$_POST["hidden"];
$con=mysql_connect("localhost","root","");

mysql_select_db("abhi",$con);

$sql="select * from userrecord where id='$hidden'";

$result=mysql_query($sql);
while($row=mysql_fetch_array($result))
{
echo '<form action="finalupdate.php" method="post">';

echo 'id<input type="text" name="id" value="'.$row['id'].'">';

echo 'name<input type="text" name="name" value="'.$row['name'].'">';
echo 'contact<input type="text" name="contact" value="'.$row['contact'].'">';
echo '
email<input type="text" name="email" value="'.$row['email'].'">';
echo '
password<input type="password" name="password" value="'.$row['password'].'"> ';
echo '
<input type="hidden" name="hidden"  value="'.$row['id'].'">';
echo '
<input type="submit" value="update" name="update">';

echo '</form>';

}

?>

(e)now write code  for  finalupdate.php :

<?php
session_start();
if(!isset($_SESSION['username']))
{
                                                                     header('location:adminerror.php');
                                                                                                       
}
?>
<?php
$hidden=$_POST["hidden"];
$name=$_POST["name"];
$contact=$_POST['contact'];
$email=$_POST["email"];
$password=$_POST["password"];
$con=mysql_connect("localhost","root","");
mysql_select_db("abhi",$con);
$sql="update userrecord set name='$name',contact='$contact',email='$email',password='$password'where id='$hidden'";
mysql_query($sql)or die(mysql_error());

echo "userrecord update successfully";
?>

(f)now write code for  delete.php:

<?php
$hidden=$_POST["hidden"];
$con=mysql_connect("localhost","root","");
mysql_select_db("abhi",$con);
$sql="delete from userrecord where id='$hidden'";
mysql_query($sql);
echo "userrecord deleted successfully";
?>

(g)write code for adminerror.php:

<?php

echo "make login first";

echo '<a href="adminlogin.html">login</a>';

?>

(h)now write code for  adminlogout.php:

<?php

session_start();
session_destroy();
header('Location:adminlogin.html');
?>

Wednesday, 4 November 2015

CHAT-APPLICATIONS (using socket.io, express and Nodejs )

(1)First of All install Nodejs  on your Windows system:

https://nodejs.org/en/download/

(2)After  That create a folder into your D: drive and name it "chat code" & now you need to  Open your command Prompt:

& perform following  command in command prompt

step 1:

D:\>cd chat code

step 2: to install socket.io

D:\chat code>npm   install  socket.io


step 3:to install  express


D:\chat code>npm   install   express

step 4: Prepare a file name it  as   "package.json " write given code below:

{
  "name": "socket-chat-example",
  "version": "0.0.1",
  "description": "my first socket.io app",
  "dependencies": {
    "express": "4.10.2",
    "socket.io": "1.2.0"
  }
}


& save it.






(3)Now write code for    "om.js"    file code which act as server program at server side keep this file  inside "chat code" folder :

var express = require('express')
  , app = express()
  , http = require('http')
  , server = http.createServer(app)
  , io = require('socket.io').listen(server);

server.listen(8080);

// routing
app.get('/', function (req, res) {
  res.sendfile(__dirname + '/om.html');
});

// usernames which are currently connected to the chat
var usernames = {};

io.sockets.on('connection', function (socket) {

  // when the client emits 'sendchat', this listens and executes
  socket.on('sendchat', function (data) {
    // we tell the client to execute 'updatechat' with 2 parameters
    io.sockets.emit('updatechat', socket.username, data);
  });

  // when the client emits 'adduser', this listens and executes
  socket.on('adduser', function(username){
    // we store the username in the socket session for this client
    socket.username = username;
    // add the client's username to the global list
    usernames[username] = username;
    // echo to client they've connected
    socket.emit('updatechat', 'SERVER', 'you have connected');
    // echo globally (all clients) that a person has connected
    socket.broadcast.emit('updatechat', 'SERVER', username + ' has connected');
    // update the list of users in chat, client-side
    io.sockets.emit('updateusers', usernames);
  });

  // when the user disconnects.. perform this
  socket.on('disconnect', function(){
    // remove the username from global usernames list
    delete usernames[socket.username];
    // update list of users in chat, client-side
    io.sockets.emit('updateusers', usernames);
    // echo globally that this client has left
    socket.broadcast.emit('updatechat', 'SERVER', socket.username + ' has disconnected');
  });
});

(4)Now write code for file "om.html" client side   "userinterface"  keep this file inside "chat code " folder :

<style>
.button { width: 9%; background: rgb(130, 224, 255); border: none; padding: 10px; }
</style>
<script src="/socket.io/socket.io.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>
<script>

    //var socket = io.connect('http://Localhost:8080');

   //var socket = io.connect('http://vissicomp.evennode.com:8080');
   var socket=io.connect();
   //var socket = io.connect('http://192.168.1.4:8080');
 
  // on connection to server, ask for user's name with an anonymous callback

  socket.on('connect', function()
  {
    // call the server-side function 'adduser' and send one parameter (value of prompt)
    socket.emit('adduser', prompt("What's your name?"));

  });
  // listener, whenever the server emits 'updatechat', this updates the chat body
  socket.on('updatechat', function (username, data) {
    $('#conversation').append('<b>'+username + ':</b> ' + data + '<br>');
  });
  // listener, whenever the server emits 'updateusers', this updates the username list
  socket.on('updateusers', function(data) {
    $('#users').empty();
    $.each(data, function(key, value) {
      $('#users').append('<div>' + key + '</div>');
    });
  });
  // on load of page
  $(function(){
    // when the client clicks SEND
    $('#datasend').click( function() {
      var message = $('#data').val();
      $('#data').val('');
      // tell server to execute 'sendchat' and send along one parameter
      socket.emit('sendchat', message);
    });
    // when the client hits ENTER on their keyboard
    $('#data').keypress(function(e) {
      if(e.which == 13) {
        $(this).blur();
        $('#datasend').focus().click();
      }
    });
  });
</script>
<div style="float:left;width:100px;border-right:1px solid black;height:300px;padding:10px;overflow:scroll-y;">
  <b>USERS</b>
  <div id="users"></div>
</div>
<div style="float:left;width:300px;height:250px;overflow:scroll-y;padding:10px;">
  <div id="conversation"></div>
  <input id="data" style="width:200px;" />
  <input type="button" id="datasend" value="send" />
  </div>


(5)Now  run your  "om.js"  server file first:


D:\chat code>node  om.js

(6)Then  Run   client side file open any browser and type on address bar "Localhost:8080 :

"Localhost:8080"



Saturday, 31 October 2015

how-to-insert-Google-map to your website?

(1)go to  url:

(2)Then type city name & area name whose map you want:

(3)then click on share  & then click on Embed  Map:

(4)copy the   <iframe src=”  ”>   </iframe>  tag code & paste inside <body></body> tag.

(5)sample code  :
<html>
<head>
<title>map</title>
</head>
<body>
<iframe src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d3762.1266625295916!2d72.78801131404806!3d19.45010504516274!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x3be7aa3228a34c4f%3A0x7126441adfc5fdd0!2sPadmavati+Nagar+Co-operative+Housing+Society!5e0!3m2!1sen!2sin!4v1446384964240" width="600" height="450" frameborder="0" style="border:0" allowfullscreen></iframe>
</body>
</html>

How-to-Publish-AndroidApps-on-GooglePlayStore?

step 1 : first go to url link & make login using your gamil id & password:

Url=https://play.google.com/apps/publish/


Step 2:
 make payment  using debit card or credit card $25..  & IT    TAKE   ONE    DAY.




step 3: then make & fill your  payment  details.

step 4: Then go to setting  & click on Account details & enter your account details:


Step 5:  Then click on   "All applications"  & click  on   Apk  :


Step 6: Then upload your  Signed Apk file  click on  "UPload New Apk to Production" file (note: google do not accept debugged apk file so plz check first whether it is signed or not).

Step 7:after uploading you have fill  details for following things:
Store Listing
Content Rating
Pricing & Distribution

Step 8: enter your  Store Listing Details after clicking on Store Listing...





Step  9: now enter details for Content Rating  click on Content Rating :


Step 10: Enter  click on Pricing & Distribution  click on Pricing & Distribution :



Step 11:
then click on  PUBLISH ..  THEN   IT   WILL TAKE   2HRS   TO   5HRS   TO  PUBLISH .

SEE YOUR ALERT ON LEFT HAND SIDE WHICH WILL SHOW YOU THE NOTIFICATIONS..

Friday, 30 October 2015

ORACLE-PL-SQL COMPLETE GUIDANCE WITH EXAMPLE

INTRODUCTION TO PL/SQL :

       Procedural Language/Structured Query Language
       PL/SQL is Very Usefully Language and Tools of Oracle to Manipulate, Control, Validate, and Restricted the Unauthorized Access of Data from the Database.
       PL/SQL can improve the Performance of an Application and it is dealing with Error and return User Friendly Error Message.
Advantages PL/SQL   :
       Procedural Language Supported.
       Reduces Network Traffic .
       Error Handling .
       Declare Variable. 
       Intermediate Calculation.
       Portable Application. 

PL/SQL Block   :

PL/SQL Block consists of three sections:
       The Declaration section (optional).
       The Execution section (mandatory).
       The Exception (or Error) Handling section (optional).



 PL/SQL Block  :
DECLARE

     Variable declaration

BEGIN
     Program Execution

EXCEPTION

     Exception handling

END;


Basic  Example  :
DECLARE
message varchar2(20):= 'Hello, World!';
BEGIN
dbms_output.put_line(message);
END;



PL/SQL DATA TYPE:

       Number type
Example :
no    number:=10;
(The NUMBER datatype is used to store fixed-point or floating-point numbers)
       Character type
(CHAR data type is used to store fixed-length character data)
Example:
grade  CHAR(1);
.VARCHAR2
(The VARCHAR2 data type is used to store variable-length character data)
.Datetime  type
(The Datetime data types lets us store and manipulate dates, times, and intervals (periods of time). )
 .Boolean type:
(BOOLEAN data type is used to store the logical values TRUE, FALSE and NULL (which stand for a missing, unknown, or inapplicable value).)



IF-THEN :

Syntax:
IF condition THEN
{
...statements to execute when condition is TRUE...
}
END IF;
If-then example:
declare
no number:=&n;
begin
if no>0 then
dbms_output.put_line('is positive');
end if;
end;



IF-THEN-ELSE :

Syntax:
IF condition THEN
{
...statements to execute when condition is TRUE...
}
ELSE
 {
...statements to execute when condition is FALSE...
}
END IF;


Example:

declare
no number:=&n;
begin
if no>0 then
dbms_output.put_line('is positive');
else
dbms_output.put_line('is negative');
end if;
end


IF-THEN-ELSIF-ELSE :

Syntax:
IF   condition1    THEN
{
...statements to execute when condition1 is TRUE...
}
ELSIF   condition2   THEN
{
...statements to execute when condition2 is TRUE...
}
ELSE
 {
...statements to execute when both condition1 and condition2 are FALSE...
}
 END IF;


Example :

DECLARE
  grade CHAR(1);
BEGIN
  grade := 'B';
 
  IF grade = 'A' THEN
    DBMS_OUTPUT.PUT_LINE('Excellent');
  ELSIF grade = 'B' THEN
    DBMS_OUTPUT.PUT_LINE('Very Good');
  ELSIF grade = 'C' THEN
    DBMS_OUTPUT.PUT_LINE('Good');
  ELSIF grade = 'D' THEN
    DBMS_OUTPUT. PUT_LINE('Fair');
  ELSIF grade = 'F' THEN
    DBMS_OUTPUT.PUT_LINE('Poor');
  ELSE
    DBMS_OUTPUT.PUT_LINE('No such grade');
  END IF;
END








 CASE  in PL_SQL example  :

DECLARE
  grade CHAR(1);
BEGIN
  grade := 'B';
 
  CASE

    WHEN grade = 'A' THEN DBMS_OUTPUT.PUT_LINE('Excellent');
    WHEN grade = 'B' THEN DBMS_OUTPUT.PUT_LINE('Very Good');
    WHEN grade = 'C' THEN DBMS_OUTPUT.PUT_LINE('Good');
    WHEN grade = 'D' THEN DBMS_OUTPUT.PUT_LINE('Fair');
    WHEN grade = 'F' THEN DBMS_OUTPUT.PUT_LINE('Poor');

  END CASE;

EXCEPTION
  WHEN      CASE_NOT_FOUND      THEN
     DBMS_OUTPUT.PUT_LINE('No such grade');
END;




WHILE   Loop  :

Syntax:
WHILE  condition 
LOOP
{
...statements...
}
END LOOP;

Example:
declare
n number:=1;
begin
while n<10
loop
dbms_output.put_line(n);
n:=n+1;
end loop;
end;


For  loop  :

Syntax:
FOR  loop_counter IN [REVERSE] lowest_number..highest_number
LOOP
{
...statements
...}

END LOOP;

Example:

declare
i number;
begin
for i in 1..10
Loop
dbms_output.put_line(i);
end loop;
end;



Cursor    in   PL-SQL  :

(1)Simple   way   select     statement   in   pl-sql :

declare
eno       int;
ename   varchar(200);
begin
select  id,name into eno,ename  from mytest where id='1';
dbms_output.put_line(eno||ename);
end;

(2) SELECT   USING     %TYPE:
declare
eno       mytest.id%type;
ename   mytest.name%type;
begin
select  id,name  into  eno  ,  ename  from   mytest   where id='1';
dbms_output.put_line(eno||ename);
end;


 (3)cursor example  with %rowtype :
declare
en  mytest%rowtype;
cursor c1   is  select   *   from  mytest;
begin
open c1;
loop
fetch c1 into en;

dbms_output.put_line(en.id||en.name);

exit when c1%notfound;

end  loop;
close c1;

end;



 (4)cursor  with %type example:
declare
en        mytest.id%type;
ename    mytest.name%type;

cursor c1   is  select   id,name   from  mytest  where id=1;
begin
open c1;
loop
fetch c1 into en,ename;

dbms_output.put_line(en||ename);

exit when c1%notfound;

end  loop;
close  c1;

end;


 (5) parameterized      Cursor :
declare
myno number;
cursor c1(en number)  is  select   *   from mytest where id=myno;
res  c1%rowtype;
begin
myno:=&en;
open c1(myno);

loop
fetch c1  into res;

dbms_output.put_line(res.id||res.name);

exit  when    c1%notfound;

end  loop;
close  c1;

end;