Search This Blog

09 December 2019

Publishing Android App in Google PlayStore Ionic

Publishing Android Application In Google Playstore


first step release the build App  Open the  Command Prompt the change directory for your project directory and Switch your Ionic project App Directory 

second step you need to add android platform to add and run the command in command prompt it will take some times reason for download the repository the if you want to check if platform automatically added under project Directory 

$ionic cordova platform add android

third step you create  unsigned APK  or release apk  open command prompt run this command it will take some time

$Ionic Cordova build android –prod –release

fourth step You will  Create Keystore file --> open the command prompt 

Run this Command

$keytool -genkey -v –keystore your_keystore_name.keystore -alias alias_name -keyalg  RSA -keysize 2048 -validity 10000

Sign the unsigned apk with jarsigner tool  run this command prompt

$jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore your_keystore_name.keystore  platforms\android\app\build\outputs\apk\release\  app-release-unsigned.apk alias_name

Zip Align tool is used to optimize the APK

this zipalign tool is located your appdata/local/android  sdk build tools so exaple my 
directory path :

C:\Users\test\AppData\Local\Android\sdk\build-tools\27.0.1\Zipalign.exe  copy this zipalign.exe its a execute java file Then paste into your Ionic project  Directory
(or) another method is available for zipalign command copy this "C:\Users\test\AppData\Local\Android\sdk\build-tools\27.0.1\Zipalign.exe" path 
right click the computer select the properties open the window select advanced system setting open the popup select the tab for advanced then click the environment variables button select path --> edit paste it the path then okie save it then check run the command for zipalign its working fine this method is permanently 


$zipalign -v 4 platforms\android\app\build\outputs\apk\release\app-release-unsigned.apk your_app.apk


Google play console case $25 USD

Click Create Application   and Fill the Description of App and Providing Screen Shots and Additional Info then Upload the signed APK that was generated  and Publish the App

 


29 November 2019

ReactJs Add Dynamic Controls and Get Dynamic Values

Attributes:
       
HTML                           Reactjs

For                                 htmlfor
class                              className

Add dynamic components and get values

styles:
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen",
    "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue",
    sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

code {
  font-family: source-code-pro, Menlo, Monaco, Consolas, "Courier New",
    monospace;
}
.name{
  border: none;
  padding-top: 36px;
  font-size: 40px;
  font-weight: 800; 
  opacity: none;
  background: transparent;
}
.name::placeholder{
font-size:40px;
font-weight: 800; 
color: blue;
}
input#lname {
  color: black;
  border: none;
  font-size: 40px;
  font-weight: 800;
  padding-bottom: 36px;
}
.form-control:focus{
  box-shadow: none;
}
.placecolor{
  opacity: 0.3;
}
input#spl {
  color: black;
  font-size: 16px;
  font-weight: 700;
  padding-bottom: 22px;
  border: none;
  background: transparent;
}
img#profile {
  width: 80%;
  border-radius: 150px;
  cursor: pointer;
}
#bar{
  border-bottom: 1px solid #80808038;
  padding: 9px;
}

input.inpt {
  border: none;
  font-size: 16px;
  font-weight: 500;
  color: #367fe6;
}
.inpt:focus{
  box-shadow: none;
  outline: none;
}
.inpt::placeholder{
font-size:16px;
font-weight: 500;
color: #367fe6;
}
textarea {
  overflow: auto;
  resize: none;
  border: none;
  height: 5pc;
  width: 90%;
}
textarea:focus {
 box-shadow: none;
outline: none;
}
ul.skls {
  margin-top: 21px;
  line-height: 34px;
  font-size: 18px;

}

progress {
  margin: 4px 0px 0px 33px;
  height: 20px;
  width: 100%;
}
progress::-webkit-progress-value { background:#2196F3!important; }
textarea.educat {
  height: 237px;
  width: 101%;
  overflow: hidden;
  text-align: justify;
}
input.detail {
  border: none;
  font-size: 16px;
  font-weight: 500;
  color: #000;
}
.detail::placeholder{
  color: #000;
}
.detail:focus{
  box-shadow: none;
  outline: none
}
textarea.test {
  height: 22px;
  overflow: hidden;
  color: #000;
  font-weight: 500;

}

Design:

 <div className="col-md-5"> <ul type="none"> <div className="fname" placeholder="PAUL" contentEditable="true" onInput={this.name.bind(this)}  id="fname">{  this.state.dynamicbox.map((value,key)=>{return(<input type="text" id={"test"+key} onkeyup={this.dynamicvalues.bind(this,key)} />);});}

           </div> <button onclick={this.addtextbox.bind(this)} > add</button><button onclick={this.removetextbox.bind(this)} > Remove</button>         </div>          
Styles:



.fname{
  font-size: 42px;

  font-weight: 800 !important;
  color:#38a7e4;
  outline: none;
  line-height: 1.2;
  cursor: text;
  text-transform:uppercase;
}
.fname[contentEditable][placeholder]:empty::before{
  content: attr(placeholder);
  color: #38a7e4;
}
.fname[contentEditable][placeholder]:focus::before{
 opacity:.2;
}


Codes:

class resume extends Component{

constructor(){
  super();
   this.state={ 
    name:"",
    dynamicbox:[""],
    dynamicvalues:[]
}

name(e){
this.setstate({
//content Editable
name:e.target.innerHTML

//form Components
name:e.target.value

)}
}


addtextbox(){
this.setState({
  dynamicbox:[...this.state.dynamicbox," "]
})
}

removetextbox(e){
  this.state.dynamicbox.splice(e,1);
this.setState({
  dynamicbox:this.state.dynamicbox
})
}

dynamicvalues(value,key){
this.state.dynamicvalues[value]=key.target.value;
this.setstate({
dynamicvalues:this.state.dynamicvalues
)}

}
date(value,key){
  const monname=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];
  var dt3=monname[key.target.value.getMonth()]+" "+key.target.value.getFullYear();
  this.state.projectdate[value]=dt3;
  this.setState({
    projectdate:this.state.projectdate
  })
  console.log(this.state.projectdate)
}

}


26 November 2019

React Js Using Login and Signup Page

Prerequisite:


i) Install node js 
ii) open cmd prompt check node is installed type node -v
iii) type npm install -g Create-react-app -->global


Reactjs Create First App:


i)open cmd prompt npx create-react-app login_signup_app
it will take some times for installed dependency

ii) Install Dependency  npm i axios react-router-dom  if you want any npm package installed it npm i (packagename)

iii) switch the under login_signup_app/src   directory your files is located 

iv) then you want create new file or folder your wish 

v) i have create 2 file login.js and signup.js , App.js -->Default file



Code:



App.js:


// import the modules

import  React,{Component} from 'react';

//imported 2 files

import Login from './login';
import Signup from './signup';

import axios from 'axios';

import $ from 'jquery-confirm';

import {

  BrowserRouter as Router,

  Switch,

  Route,

  NavLink,

  Link

} from "react-router-dom";

export default class App extends Component{constructor(){    super();   }

render(){

  return(

    <div>

       <Router>

      <nav className="header">

           <ul type="none" className='nav' >

          <li>

               <NavLink exact activeClassName="active"  to="/">Home</NavLink>

             </li>

             <li>

               <NavLink  to="/login">Login</NavLink>

             </li>

             <li>

               <NavLink  to="/signup">Signup</NavLink>

             </li>

            

           </ul>

         </nav>

         <Switch>         

           <Route exact  path="/" component={Home} />    

           <Route  path="/login" component={Login} />        

           <Route  path="/signup" component={Signup} />        

         </Switch>

         </Router>

    </div>

  )

}

}

class Home extends Component{

constructor(){    super();

}

//file upload Function

upload(e){
  this.setState({
    file:e.target.files[0].name 
  })
  var rdr=new FileReader();
rdr.onload=function(t){
  document.getElementById('profile').src=t.target.result;
}
rdr.readAsDataURL(e.target.files[0]);
const fd=new FormData();
fd.append("image",e.target.files[0]);
 axios({
  method:'post', url:'file.php',
  data:fd ,
  config:{headers:{'content-type': 'multipart/form-data'}}
}).then(function(res){
console.log(res)
}).catch(function(err){
console.log(err)
});

render(){  

return(<div>

//Defalut Page HTML CODES Here

</div>

)}



Login.js:


export default class Login extends Component{

constructor(){

    super();

    this.state={

        email:"",

        pwd:""

    }

}

    email(e){

        this.setState({

            email:e.target.value

        })

    }

    pwd(e){

        this.setState({

            pwd:e.target.value

        })

    }  

login(event){

    var name=this.state.email;

    var pwd=this.state.pwd;

    var sp1=document.getElementById('nm');

var sp2=document.getElementById('pd');

    if(name.length==0 && pwd.length==0){

console.log("Required fileds");

sp1.style.display="block";

sp2.style.display="block";

event.preventDefault();

    }else if(name.length==0 ){

        console.log("Required email");

        sp1.style.display="block";

sp2.style.display="none";

        event.preventDefault();

    }else if(pwd.length==0){

        console.log("Required passwd");

        sp1.style.display="none";

sp2.style.display="block";

        event.preventDefault();

    }else{

        axios({

            url:'http://localhost/sign.php',

            method:'post',

            data:{

              useremail:this.state.email,

              userpwd:this.state.pwd

            },

            headers:{'Access-Control-Allow-Origin': '*'}  

          }).then(function (res){    

              console.log(res.data);

              document.getElementById('frm').reset();

              $.alert({

                  title: 'Message!',

                  content: 'Login Successfully',

              });

          }).catch(function (err){          

          });

    }

    sp1.style.display="none";

    sp2.style.display="none";

}        

    render(){

        return(

<div style={{backgroundImage:"url(bg.jpg)",height:"85vh"}}>   

    <div className="container">

        <div className="row">

           <div className="col-md-4"></div>

           <div className="col-md-5 box">

            <h2 className="text-center">Login Page</h2>

            <form id='frm'>

            

            <div className="form-group">

               <label>Email</label>

               <input type="text" onKeyUp={this.email.bind(this)} className="form-control" placeholder="Enter Email"></input>

               <span id="nm" style={{display:"none",color:"red"}}>Email is Required</span>

            </div>

            <div className="form-group">

               <label>Password</label>

               <input type="password" onKeyUp={this.pwd.bind(this)} className="form-control" placeholder="Enter Password"></input>

               <span id="pd" style={{display:"none",color:"red"}}>Pasword is Required</span>

            </div>

             <lable style={{cursor:"pointer"}}  onClick={this.login.bind(this)}   className="btn btn-primary" >Login</lable>

             </form>

             <br/>

            </div>

            <div className="col-md-1"></div>

        </div>       

    </div>

</div>

        );

    }


Signup.js:



import React,{Component} from 'react';

import axios from 'axios';

import './register.css';

import $ from 'jquery-confirm';

export default class Signup extends Component{

constructor(){

    super();

    this.state={

        uname:"",

        email:"",

        pwd:""

    }

}

name(e){

    this.setState({

        uname:e.target.value

    })

}

email(e){

    this.setState({

        email:e.target.value

    })

}

pwd(e){

    this.setState({

        pwd:e.target.value

    })

}    

    signup(){

axios({

  url:'http://localhost/sign.php',

  method:'post',

  data:{

    username:this.state.uname,

    email:this.state.email,

    passwd:this.state.pwd

  },

  headers:{'Access-Control-Allow-Origin': '*'}  

}).then(function (res){    

    console.log(res.data);

    document.getElementById('frm').reset();

    $.alert({

        title: 'Message!',

        content: 'Register Successfully',

    });

}).catch(function (err){

});

    }

    render(){

        return(

<div style={{backgroundImage:"url(bg.jpg)",height:"85vh"}}>   

    <div className="container">

        <div className="row">

           <div className="col-md-4"></div>

           <div className="col-md-5 box">

            <h2 className="text-center">Register Page</h2>

            <form id='frm'>

            <div className="form-group">

               <label>Username</label>

               <input type="text" onKeyUp={this.name.bind(this)} className="form-control" placeholder="Enter Username"></input>

            </div>

            <div className="form-group">

               <label>Email</label>

               <input type="text" onKeyUp={this.email.bind(this)} className="form-control" placeholder="Enter Email"></input>

            </div>

            <div className="form-group">

               <label>Password</label>

               <input type="password" onKeyUp={this.pwd.bind(this)} className="form-control" placeholder="Enter Password"></input>

            </div>

             <lable style={{cursor:"pointer"}} onClick={this.signup.bind(this)}  className="btn btn-primary" >Register</lable>

             </form>

             <br/>

            </div>

            <div className="col-md-1"></div>

        </div>       

    </div>

</div>

        );

    }

}



Signup.php:



<?php

header("Access-Control-Allow-Origin: *");

header("Access-Control-Allow-Headers: *");

$con=mysqli_connect("localhost","root","","test");

$data = json_decode(file_get_contents('php://input'), true);

@$name=$data['username'];

@$email=$data['email'];

@$pwd=$data['passwd'];

@$useremail=$data['useremail'];

@$userpwd=$data['userpwd'];

if(!empty($name)){

$sql="insert into signup values(NULL,'$name','$email','$pwd')";

$con->query($sql);

echo "Inserted...💜";

}else{    

}

if(!empty($useremail)){

    $sql="select * from signup where Email='$useremail' and Password='$userpwd'";

    $res=$con->query($sql);

    $cnt=mysqli_num_rows($res);

    if($cnt==1){

echo "Login Successfully..🤩";

    }else{

echo "Email or Password is Incorrect..😫";

    }    

}else{   

}

?>

Output:
















22 July 2019

Ionic 3 using Push Notification

Ionic 3 using Push Notification With Firebase

Firebase:

firebase  is google platform its used mobile and web application , google provide  some features  like as  in app messaging , firebase push notification , google cloud messaging , remote config , firebase cloud function , firebase database and firebase firestore if you use firebase in your app is high_quality application, relabel and more fast

Steps:

Login Into Your Gmail Account 

search Firebase to Google --> Open Console  -> create New Project ---> etc...Open Project  (android,ios,web) --> select oneI choose AndroidRegister App  --> com.yournameapp.app  ( your Config.xml file id like same as       com.yournameapp.app) 

Nick Name --> Optional if you want to give or not necessary Register AppDownload Googleservice.json File Copy this File Under Root Directory of Your Project  

Add FireBase SDK to Your Build.gradle file platform/android/...etc

Install this Plugin ana open the cmd prompt change directory to switch your project directory and run this command 

$ionic cordova plugin add cordova-plugin-fcm-with-dependency-updated

$npm install @ionic-native/fcm@4 --save

then open your project under src/ app

select app.modules.ts open this file -->add the modeuls 

var firebaseConfig = {  

apiKey: "fgfhg", 

 authDomain: "test-9c526.firebaseapp.com", 

 databaseURL: "https://test-9c526.firebaseio.com", 

 projectId: "test-9c826",  

storageBucket: "test-9c526.appspot.com",

  messagingSenderId: "54354353545", 

 appId: "1:34844348772050:web:d775454f03f53fe10cee0tgg86a8b"

};

@NgModule({ 

 declarations: [   MyApp,    HomePage  ], 

 imports: [    BrowserModule,    AngularFireAuthModule,    AngularFireDatabaseModule,    AngularFireModule.initializeApp(firebaseConfig),    IonicModule.forRoot(MyApp)  ],  bootstrap: [IonicApp],  entryComponents: [    MyApp,    HomePage  ], 

 providers: [    StatusBar,    AdMobFree,    Geolocation,    Diagnostic,    NativeGeocoder,    SocialSharing,    SplashScreen,    CallNumber,    {provide: ErrorHandler, useClass: IonicErrorHandler}  ]})

constructor(public navCtrl: NavController,public afd: AngularFireDatabase) {    this.tokensetup().then((token) => { 

     this.storetoken(token);    

})  }  

ionViewDidLoad()  { 

FCMPlugin.onNotification(function(data){    if(data.wasTapped){      // Notification was received on device tray and tapped by the user.    

   }else{      

// Notification was received in foreground. Maybe the user needs to be notified.       }    });

FCMPlugin.onTokenRefresh(function (token){});     } 

tokensetup() {   

 var promise = new Promise(( resolve, reject) => {  

    FCMPlugin.getToken( function (token){   

 resolve (token);      },

 (err) => {     

  reject (err);  });   

 })    return promise;  } 

 storetoken(t) {   

 this.afd.list(this.firestore).push({      uid: " user1 ",     devtoken: t    }).then(() => {   }).catch(() => {      //  alert (' Token not stored ');      }) }

Build Apk  installe it then Verify sdk the  go to google  cloud Messaging tab send message give notification name and title , target the app , sounds are enable or not then finally send or draft

19 June 2019

Ionic 3 Login With Firebase

Steps: 

create the ionic project run the command 

$ionic start blank myapp --type=ionic-angular

then open the command prompt  change the directory of your ionic project directory the install the some modules are here  down see this

Go To The Firebase Console -->   Authentication menu ---> SignIn-method tab

 -->Edit  -> Enable Allow users Only (First Toggle Button)  ---> Save


Install NPM Modules:

installed this module open the command prompt  run this command

npm i rxjs@6 rxjs-compat@6 promise-polyfill --save (or)  npm install rxjs@6.0.0 --save

npm install firebase  angularfire2 --save


Import Your Modules In App.module.ts And Yourfile.Ts


App.Module.ts


import {AngularFireModule} from 'angularfire2';
import {AngularFireDatabaseModule,AngularFireDatabase} from 'angularfire2/database';
import {AngularFireAuthModule} from 'angularfire2/auth';
 imports: [
    BrowserModule,
    AngularFireAuthModule,
    AngularFireDatabaseModule,
    AngularFireModule.initializeApp(firebaseConfig),
    IonicModule.forRoot(MyApp)
  ],
  bootstrap: [IonicApp],
  entryComponents: [
    MyApp,
    HomePage
  ],
  providers: [
    StatusBar,
     SocialSharing,
    SplashScreen,
    CallNumber,
    {provide: ErrorHandler, useClass: IonicErrorHandler}
  ]
})

Imports:


AngularFireModule.initializeApp(firebaseConfig),
    AngularFireAuthModule,
   AngularFireDatabaseModule

YourFileName.TS:

  iimport { IonicApp, IonicErrorHandler, IonicModule } from 'ionic-angular';
import { SplashScreen } from '@ionic-native/splash-screen';
import { StatusBar } from '@ionic-native/status-bar';
import { MyApp } from './app.component';
import { HomePage } from '../pages/home/home';
import {AngularFireModule} from 'angularfire2';
import {AngularFireAuthModule} from 'angularfire2/auth';
import {AngularFireDatabaseModule}from 'angularfire2/database';
import { CallNumber } from '@ionic-native/call-number';
import { Geolocation } from '@ionic-native/geolocation';
import { NativeGeocoder, NativeGeocoderReverseResult, NativeGeocoderForwardResult, NativeGeocoderOptions } from '@ionic-native/native-geocoder';
import { Diagnostic } from '@ionic-native/diagnostic';
import { SocialSharing } from '@ionic-native/social-sharing';


Codes:

Register Firebase Authentication:

// form validation method
Register(formData){
if(!formData.valid){
this.RegisterForm.get(' Fname ').markAsDirty();
this.RegisterForm.get(' Lname ').markAsDirty();
this.RegisterForm.get(' Username ').markAsDirty();
this.RegisterForm.get(' Email ').markAsDirty();
this.RegisterForm.get(' Password ').markAsDirty();
}else{
// here store the firebase database  
this.fdb.list(" /register/ ").push({
Fname:formData.value.Fname,
Lname:formData.value.Lname,
Username:formData.value.Username,
Email:formData.value.Email,
Password:formData.value.Password
});
// Your Email and Passwords  are Stored in Firebase Signin Method
return this.ath.auth.createUserWithEmailAndPassword(formData.value.Email,formData.value.Password).then(() => {

this.RegisterForm.reset();
let toast = this.toast.create({
      message:  'Register SuccessFully ',
      position: ' bottom ',
      duration: 4000
    });
    toast.present();

})
}
}

Login:

Login(formData){
if(!formData.valid){
// form validation method
this.LoginForm.get('Email').markAsDirty();
this.LoginForm.get('Password').markAsDirty();
}else{

// Login Authentication with Firebase database
return this.ath.auth.signInWithEmailAndPassword(formData.value.Email,formData.value.Password).then(()=>{
this.navCtrl.setRoot(HomePage)
},error =>{
let toast=this.toast.create({
message: ' UserName or Password Is Wrong ',
      position: ' bottom ',
      duration: 4000
});
toast.present();
})

}
}

Signout:

signOut() {  return this.ath.auth.signOut();}





Ionic 3 and Firebase Using database

Ionic 3 and Firebase Using database 

Create Ionic Project :

Ionic Start [Projectname] Blank --type=ionic-angular

Switch Project Directory

Create Firebase Account the create New  Project  then get web API config copy the Web Config  Paste the Your App.module.js

import {AngularFireModule} from 'angularfire2';
import {AngularFireDatabaseModule,AngularFireDatabase} from 'angularfire2/database';
import {AngularFireAuthModule} from 'angularfire2/auth';
import { MyApp } from './app.component';
import { HomePage } from '../pages/home/home';

const firebaseConfig = {
  apiKey: "AIzaSyCze4AwyQNqNQqHId1ZoSUVBPQptN_NXwQ",
  authDomain: "firedb-49c70.firebaseapp.com",
  databaseURL: "https://firedb-49c70.firebaseio.com",
  projectId: "firedb-49c70",
  storageBucket: "firedb-49c70.appspot.com",
  messagingSenderId: "455535872444",
  appId: "1:455535872444:web:6ff67fe68dfeaf4d"
};

Install This NPM Modules

npm i rxjs@6 rxjs-compat@6 promise-polyfill --save 

{or)

npm install rxjs@6.0.0 --save

npm install firebase angularfire2 --save

Add The Modules in app.modules.ts

import {AngularFireModule} from 'angularfire2';

import {AngularFireDatabaseModule,AngularFireDatabase} from 'angularfire2/database';

Add the Imports:

imports: [ 
    AngularFireAuthModule, 
    AngularFireModule.initializeApp(firebaseConfig),
   AngularFireDatabaseModule
  ]

Add The Modules in Home.ts   

import {AngularFireDatabase} from 'angularfire2/database';


Codes:

home.html

<ion-header>
  <ion-navbar>
    <ion-title>
      Firebase Example
    </ion-title>
  </ion-navbar>
</ion-header>
<ion-content padding>
  <form [formGroup]="RegisterForm">
  <ion-list>
  <ion-item>
  <ion-input formControlName="Fname" type="text" placeholder="Enter Your FirstName"></ion-input>
  </ion-item>
  <div class="red" *ngIf="RegisterForm.controls.Fname.value=='' && !RegisterForm.controls.Fname.valid && RegisterForm.controls.Fname.dirty">
  Enter User Fname
  </div>
  <ion-item>
  <ion-input formControlName="Lname" type="text" placeholder="Enter Your LastName"></ion-input>
  </ion-item>
  <div class="red" *ngIf="RegisterForm.controls.Lname.value=='' && !RegisterForm.controls.Lname.valid && RegisterForm.controls.Lname.dirty">
  Enter User Lname
  </div>
  <ion-item>
  <ion-input formControlName="Username" type="text" placeholder="Enter Your UserName"></ion-input>
  </ion-item>
  <div class="red" *ngIf="RegisterForm.controls.Username.value=='' && !RegisterForm.controls.Username.valid && RegisterForm.controls.Username.dirty">
  Enter User Name
  </div>
  <ion-item>
  <ion-input formControlName="Email" type="text" placeholder="Enter Your Email"></ion-input>
  </ion-item>
  <div class="red" *ngIf="RegisterForm.controls.Email.value=='' && !RegisterForm.controls.Email.valid && RegisterForm.controls.Email.dirty">
  Enter User Email
  </div>
  <ion-item>
  <ion-input formControlName="Password" type="password" placeholder="Enter Your Password"></ion-input>
  </ion-item>
  <div class="red" *ngIf="RegisterForm.controls.Password.value=='' && !RegisterForm.controls.Password.valid && RegisterForm.controls.Password.dirty">
  Enter User Password
  </div>
<button ion-button color="secondary" full (click)="Register(RegisterForm)">Register</button>
  </ion-list>
  </form>
<div class="row header">
<div class="col"> Fname</div>
<div class="col">Lname</div>
<div class="col">Username</div>
<div class="col">Email</div>
<div class="col">Password</div>
</div>
<div class="row s" *ngFor="let row of records">
<div class="col">{{ row.Fname }}</div>
<div class="col">{{ row.Lname }}</div>
<div class="col">{{ row.Username }}</div>
<div class="col">{{ row.Email }}</div>
<div class="col">{{ row.Password }}</div>
</div>
</ion-content>

Home.ts

import { Component } from '@angular/core';
import { NavController,ToastController} from 'ionic-angular';
import {AngularFireDatabase} from 'angularfire2/database';
import {Validators,FormGroup,FormControl} from '@angular/forms';
@Component({
  selector: 'page-home',
  templateUrl: 'home.html'
})
export class HomePage {
RegisterForm:FormGroup;
records;
  constructor(public navCtrl: NavController,private fdb:AngularFireDatabase,public toast:ToastController) {
this.formInit()
  }
  formInit(){
this.RegisterForm = new FormGroup({
Fname: new FormControl("",[Validators.required,Validators.maxLength(10)]),
Lname: new FormControl("",[Validators.required,Validators.maxLength(10)]),
Username: new FormControl("",[Validators.required,Validators.maxLength(10)]),
Email: new FormControl("",[Validators.required,Validators.maxLength(30)]),
Password: new FormControl("",[Validators.required,Validators.maxLength(20)])
});
}
Register(formData){
if(!formData.valid){
this.RegisterForm.get('Fname').markAsDirty();
this.RegisterForm.get('Lname').markAsDirty();
this.RegisterForm.get('Username').markAsDirty();
this.RegisterForm.get('Email').markAsDirty();
this.RegisterForm.get('Password').markAsDirty();
}else{
this.fdb.list("/register/").push({
Fname:formData.value.Fname,
Lname:formData.value.Lname,
Username:formData.value.Username,
Email:formData.value.Email,
Password:formData.value.Password
});
let toast = this.toast.create({
      message: 'Register SuccessFully',
      position: 'bottom',
      duration: 4000
    });
    toast.present();
this.RegisterForm.reset();
}
}
ionViewDidLoad(){
this.fdb.list('/register').snapshotChanges().subscribe((res) => {
let tempar:any = [];
res.forEach((ele) => {
tempar.push(ele.payload.val())
});
this.records=tempar;
})
}
}

Home.Scss

 page-home {
.red {
    background-color: #eca7a799;
    color: #e01414d1;
    width: 94%;
    height: 35px;
    padding: 8px;
    margin: 6px 1px 1px 41px;
    border-radius: 10px;
}
.header .col {
  background-color: #49c2f3;
}
    .row.header {
    margin-top: -12px;
    margin-left: -16px;
    margin-right: -15px;
    }
    .row.s {
    margin-left: -15px;
    margin-right: -21px;
}
}

Output:








Ionic 3  Store Data With Fire Store


Install this NPM:

npm install firebase@6 angularfire2  rxjs@6.0.0  rxjs-compat --save

App.Module.ts:

      import {AngularFireModule} from 'angularfire2';
    import {AngularFirestore,AngularFirestoreModule} from 'angularfire2/firestore';
      var firebaseConfig = {
       apiKey: "",
       authDomain: "",
      databaseURL: "",
       projectId: "",
       storageBucket: "",
        messagingSenderId: "",
         appId: ""
  };
imports: [
    BrowserModule,
    AngularFirestoreModule,
     AngularFireModule.initializeApp(firebaseConfig),
    IonicModule.forRoot(MyApp)
  ],


YourHtml.js:

import { AngularFirestore, AngularFirestoreCollection }  from 'angularfire2/firestore';
import { Observable } from 'rxjs';


export class HomePage {
RegisterForm:FormGroup;
private userreg: AngularFirestoreCollection<Users>;
  constructor(public navCtrl: NavController,private afs:AngularFirestore) {
this.formInit();
  }
formInit(){
this.RegisterForm = new FormGroup({
Username: new FormControl("",[Validators.required,Validators.maxLength(20)]),
Password: new FormControl("",[Validators.required,Validators.maxLength(20)])
});
this.userreg=this.afs.collection<Users>('users')
}

signup(formData){
if(!formData.valid){
this.RegisterForm.get("Username").markAsDirty();
this.RegisterForm.get("Password").markAsDirty(); 
}else{
let userdata={
username:formData.get("Username").value,
password:formData.get("Password").value
}
const id = this.afs.createId();
 this.userreg.doc(id).set(userdata);
}
}


}








07 January 2019

Codeigniter Using CRUD

Codeigniter Using CRUD


Change The Configuration in Config File:

Open root folder/Application/Config-> Autoload.php 

$autoload['libraries'] = array('database','session');

Open root folder/Application/Config-> database.php


'hostname' => 'localhost',
'username' => 'root',
'password' => '',
'database' => 'Your DB Name',
'dbdriver' => 'mysqli',

Create  One  Controller File :

<?php
Class Crud extends CI_Controller
{
}  ?>

Create One Model File:

<?php
Class Crud extends CI_Model
{
}  ?>

Controller:

<?php
/**
 * 
 */
Class Crud extends CI_Controller
{
public function __construct()
{
parent::__construct();
$this->load->database();
$this->load->model('Crud_model');
$this->load->helper('url');
}
public function select(){
$result['data']=$this->Crud_model->select();
$this->load->view('select',$result);
}
public function insert(){
$this->load->view('index');
if($this->input->post('s')){
$name=$this->input->post('nme');
$gender=$this->input->post('gen');
$res=$this->input->post('res');
$config['upload_path']="./images";
$config['allowed_types']="png|jpg|gif";
$this->load->library('upload',$config);
$file="Image";
if($this->upload->do_upload($file)){
             $img=$this->upload->data('file_name');
$this->db->query("Insert into crud values(NULL,'$name','$gender','$res','$img')");
}else{
echo $this->upload->display_errors();
}
}
}


public function delete(){
$del=$this->input->get('del');
$this->Crud_model->delete($del);
redirect('/Crud/select');
}
public function show(){
$id=$this->input->get('up');
$data['result']=$this->Crud_model->show($id);
$this->load->view('show',$data);
if($this->input->post('sub')){
$name=$this->input->post('nme');
$gender=$this->input->post('gen');
$res=$this->input->post('res');
$config['upload_path']="images";
$config['allowed_types']="jpg|png|gif";
$this->load->library('upload'config);
$file="image";
if($this->upload->do_upload($file)){
$img=$this->upload->data('file_name');
$sql="update crud set name='$name',gender='$gender',result='$res',image='$img' where id='$id'";
$this->db->query($sql);
redirect('/Crud/select');
}
}
}



}



?>

Model File:

index.php

   <?php

   Class Crud_model extends CI_Model{

    public function select()
      {
$sql="select * from crud";
$query=$this->db->query($sql);
return $query->result();
    }

    public function delete($del){
   $sql="delete from crud where id='$del'";
$query=$this->db->query($sql);
   }

  public function show($id){
   $sql="select * from crud where id='$id'";
   $query=$this->db->query($sql);
   return $query->result();
  }

  }
  ?>

View File:

<!DOCTYPE html>
<html>
<head>
<title>Crud</title>
</head>
<body>
<table>

<form method="post" enctype="multipart/form-data">
<input type="hidden" name="<?php echo $this->security->get_csrf_token_name();  ?>" value="<?php echo $this->security->get_csrf_hash(); ?>">
<tr>
<td>Name</td><td><input type="text" name="nme" autocomplete="off" ></td>
</tr>
<tr>
<td>gender</td><td><input type="radio" name="gen" value="Male" autocomplete="off" >Male
        <input type="radio" name="gen" value="Female" autocomplete="off" >Female
</td>

</tr>
<tr>
<td>Result</td><td><select name="res"><option>Select Result</option><option>Pass</option><option>Fail</option></select></td>
</tr>
<tr>
<td>Image</td><td><input type="file" name="Image" ></td>
</tr>
</table>
<input type="submit" name="s" value="Insert">
</form>

</body>
</html>

Select.php

<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<table>
<tr><th>Name</th><th>gender</th><th>Result</th><th>Image</th></tr>
<?php foreach ($data as $row) { ?>
<tr>
<td><?php echo $row->name; ?></td>
<td><?php echo $row->gender; ?></td>
<td><?php echo $row->result; ?></td>
<td><img width="100px" height="100px" src="<?php echo base_url()."images/".$row->image; ?>"></td>
    <td><a href='<?php echo "show?up=".$row->id; ?>'>Update</a></td>
<td><a href='<?php echo "delete?del=".$row->id;  ?>'>delete</a></td>
</tr>
<?php } ?>
</table>
</body>
</html>

Update.php:

<!DOCTYPE html>
<html>
<head>
<title>Crud</title>
</head>
<body>
<table>

<form method="post" enctype="multipart/form-data">
<?php foreach ($result as $row) {
?>
<input type="hidden" value="<?php  echo $row->id; ?>">
<input type="hidden" name="<?php echo $this->security->get_csrf_token_name(); ?>" value="<?php echo $this->security->get_csrf_hash(); ?>">
<tr>
<td>Name</td><td><input value="<?php echo $row->name ?>" type="text" name="nme" autocomplete="off" ></td>
</tr>
<tr>
<?php if($row->gender=="Male") {?>
<td>gender</td><td><input checked="true" type="radio" name="gen" value="Male" autocomplete="off" >Male
        <input type="radio" name="gen" value="Female" autocomplete="off" >Female
</td>
<?php }else{?>
<td>gender</td><td><input  type="radio" name="gen" value="Male" autocomplete="off" >Male
        <input type="radio" checked="true" name="gen" value="Female" autocomplete="off" >Female
</td>
<?php }?>
</tr><?php if($row->result=="Pass"){?>
<tr>
<td>Result</td><td><select name="res"><option>Select Result</option><option selected="true">Pass</option><option>Fail</option></select></td>
</tr><?php } else{ ?>
<tr>
<td>Result</td><td><select name="res"><option>Select Result</option><option>Pass</option><option selected="true">Fail</option></select></td>
<?php } ?>
<tr>
<td>Image</td><td><img width="200px" height="200px" src="<?php echo base_url().'images/'.$row->image;?>"></td>
</tr>
<tr>
<td>Select Image</td><td><input type="file" name="image"></td>
</tr>
</table>
<?php } ?>
<input type="submit" name="sub" value="Update">
</form>

</body>
</html>
---------------------------------------------------
Simple Steps:

$this->db->query($sql)->row //single record

// IF you Want to get More than Single Row use  (row)

single rows count 

$q=$this->db->query($sql)->row
count($q)

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

$this->db->query($sql)->rows // multiple records

// IF you Want to get More than Multiple Row use  (rows)

multiple rows Count

$q=$this->db->query($sql)->rows
$cnt=$q->num_rows();

Outputs:






Jquery or Javascript Start Exam Time

 <script> function startTimer() {      var date = "<?php echo $date ?>"; // dynamic date      var time = "<?...