php_file_insert_delete_display_update_login
//insert php file simple
<?php
error_reporting(0);
$host='localhost';
$name='root';
$pass='';
$db='mysqljson1';
$con=mysql_connect($host,$name,$pass) or die("Connection Failed...");
mysql_select_db($db,$con) or die("Db Selection Failed...");
$name = $_POST['name'];
$pass = $_POST['pass'];
$flag['code']=0;
if($qry=mysql_query("INSERT INTO `insertt`(`name`, `pass`) VALUES ('$name','$pass')"))//insertt table nu name
{
$flag['code']=1;
}
echo json_encode($flag);
echo "Hello";
mysql_close($con);
?>
//Insert php file
<?php
error_reporting(0);
$host='localhost';
$uname='root';
$pwd='';
$db='tirth';//tirth che tya database nu name lkhvanu je json ma hoy ae
$con=mysql_connect($host,$uname,$pwd) or die("Connection Failed...");
mysql_select_db($db,$con) or die("Db Selection Failed...");
$name = $_POST['name'];
$pass = $_POST['pass'];
$gen=$_POST['radio'];
$flag['code']=0;
if($qry=mysql_query("INSERT INTO `androidtable`(`name`, `pass`, `gender`) VALUES ('$name','$pass','$gen')"))//androidtable che tya table nu name lkhvanu je json ma hoy ae
{
$flag['code']=1;
}
echo json_encode($flag);
echo "Hello";
mysql_close($con);
?>
Display php file
//
<?php
error_reporting(0);
$host='localhost';
$uname='root';
$pwd='';
$db='tirth';
$con=mysql_connect($host,$uname,$pwd) or die("Connection Failed...");
mysql_select_db($db,$con) or die("Db Selection Failed...");
$result=mysql_query("select * from `androidtable`");
$json=array();
while($row=mysql_fetch_assoc($result))
{
$json["server"][]=$row;
}
echo json_encode($json);
echo "Hello";
mysql_close($con);
?>
//Delete php file
<?php
error_reporting(0);
$host='localhost';
$uname='root';
$pwd='';
$db='androidjson';
$con=mysql_connect($host,$uname,$pwd) or die("Connection Failed...");
mysql_select_db($db,$con) or die("Db Selection Failed...");
$ID = $_POST['id'];
$Sql_Query = "DELETE FROM `androidtable` WHERE `id` = '$ID'";
if(mysql_query($Sql_Query,$con))
{
echo 'Record Deleted Successfully';
}
else
{
echo 'Something went wrong';
}
mysql_close($con);
?>
//login php file
<?php
error_reporting(0);
$host='localhost';
$uname='root';
$pwd='';
$db='tirth';
$con=mysql_connect($host,$uname,$pwd) or die("Connection Failed...");
mysql_select_db($db,$con) or die("Db Selection Failed...");
$name = $_POST['name'];
$pass = $_POST['pass'];
$flag['code']=0;
$s="select * from `androidtable` where `name`='$name' and `pass`='$pass'";
$sql=mysql_query($s);
if(mysql_num_rows($sql)>0)
{
echo "success";
}
else
{
echo "fail";
}
?>
//Display php file
<?php
error_reporting(0);
$host='localhost';
$uname='root';
$pwd='';
$db='androidjson';
$con=mysql_connect($host,$uname,$pwd) or die("Connection Failed...");
mysql_select_db($db,$con) or die("Db Selection Failed...");
$result=mysql_query("select * from `androidtable`");
$json=array();
while($row=mysql_fetch_assoc($result))
{
$json["server"][]=$row;
}
echo json_encode($json);
echo "Hello";
mysql_close($con);
?>
Comments
Post a Comment