Posts

Showing posts from August, 2020

Routing problem solved in codeignitor

 Routing problem solved in codeignitor just add following lines in .htaccess for localserver like wamp or xamp RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ /index.php/$1 [L] for online server (put ? in line 5 after index.php) RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ /index.php?/$1 [L]

Android Web View Navigation removed orientation fixed

Orientation fixed means if logged in and mobile changes orientation from vertical to horizontal activity restarts if anyone is logged in its logs out automatically so it is fixed in manifest file. also if internet not available it show check internet. ***************************************************************************** MainActivity.java package com.grobharat.learningapp; import android.content.DialogInterface; import android.graphics.Bitmap; import android.os.Bundle; import android.view.View; import android.webkit.WebView; import android.webkit.WebViewClient; import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AppCompatActivity; public class MainActivity extends AppCompatActivity { private WebView webView ; @Override protected void onCreate(Bundle savedInstanceState) { super .onCreate(savedInstanceState); setContentView(R.layout. activity_main ); hideNavigationBar(); webView = (WebView) findViewById(R.id. webView

Android webview without navigation bar

Manifest.xml <? xml version ="1.0" encoding ="utf-8" ?> < manifest xmlns: android ="http://schemas.android.com/apk/res/android" package ="com.grobharat.grobharateducation" > < uses-permission android :name ="android.permission.INTERNET" /> < application android :allowBackup ="true" android :icon ="@mipmap/ic_launcher" android :label ="GroBharat Education" android :roundIcon ="@mipmap/ic_launcher_round" android :supportsRtl ="true" android :theme ="@style/AppTheme" android :networkSecurityConfig ="@xml/network_security_config" android :usesCleartextTraffic ="true" > < activity android :name =".MainActivity" > < intent-filter > < action android :name ="android.intent.action.MAIN" />

Android webview sample code

activity_main.xml <? xml version ="1.0" encoding ="utf-8" ?> < RelativeLayout xmlns: android ="http://schemas.android.com/apk/res/android" xmlns: app ="http://schemas.android.com/apk/res-auto" xmlns: tools ="http://schemas.android.com/tools" android :layout_width ="match_parent" android :layout_height ="match_parent" tools :context =".MainActivity" > < WebView android :id ="@+id/webView" android :layout_width ="match_parent" android :layout_height ="match_parent" /> </ RelativeLayout > MainActivity.java package com.grobharat.GroBharat; import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AppCompatActivity; import android.os.Bundle; import android.webkit.WebSettings; import android.webkit.WebView; import android.webkit.WebViewClient; import android.content.DialogInterface; import android.

Creating table in database using php

<?php $servername =  "localhost" ; $username =  "username" ; $password =  "password" ; $dbname =  "dbname" ; // Create connection $conn =  new  mysqli($servername, $username, $password, $dbname); // Check connection if  ($conn->connect_error) {    die ( "Connection failed: "  . $conn->connect_error); } // sql to create table $sql =  "CREATE TABLE MyGuests ( id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY, firstname VARCHAR(30) NOT NULL, lastname VARCHAR(30) NOT NULL, email VARCHAR(50), reg_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP )" ; if  ($conn->query($sql) === TRUE) {    echo   "Table MyGuests created successfully" ; }  else  {    echo   "Error creating table: "  . $conn->error; } $conn->close(); ?>

Create Database in mysql or mariadb using php

<?php $servername = "localhost"; $username = "root"; $password = ""; // Create connection $conn = new mysqli($servername, $username, $password); // Check connection if ($conn->connect_error) {   die("Connection failed: " . $conn->connect_error); } // Create database $sql = "CREATE DATABASE dbname"; if ($conn->query($sql) === TRUE) {   echo "Database created successfully"; } else {   echo "Error creating database: " . $conn->error; } $conn->close(); ?>

Create table in mysql database in phpmyadmin panel

DROP TABLE IF EXISTS `tablename`; CREATE TABLE IF NOT EXISTS `tablename` (   `id` int(11) NOT NULL AUTO_INCREMENT,   `AdminUserName` varchar(255) NOT NULL,   `AdminPassword` varchar(255) NOT NULL,   `AdminEmailId` varchar(255) NOT NULL,   `Is_Active` int(11) NOT NULL,   `CreationDate` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,   `UpdationDate` timestamp NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP,   PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1; -- -- Dumping data for table `tbladmin` -- INSERT INTO `tbladmin` (`id`, `AdminUserName`, `AdminPassword`, `AdminEmailId`, `Is_Active`, `CreationDate`, `UpdationDate`) VALUES (1, 'admin', 'password', 'admin@email.com', 1, '2019-02-10 17:51:00', '2019-02-15 08:52:44');

Read data from database in php mysql

Reading data from database in php and mysql <table >                                                         <thead>                                                             <tr>                                                                 <th>#</th>                                                               <th>Centre</th>                                                                 <th> Address</th>                                                                 <th>Contact</th>                                                                 <th>Action</th>                                                          </tr>                                                         </thead>                                                         <tbody> <?php  $query=mysqli_query($con,"Select id, CentreName,CentreAddress,CentreContact from  tblcentres where Is_Active=1");

Changing status of data in database in php mysql

<?php session_start(); include('includes/config.php'); error_reporting(0); if(strlen($_SESSION['login'])==0)   {  header('location:index.php'); } else{ if($_GET['action']=='del' && $_GET['rid']) { $id=intval($_GET['rid']); $query=mysqli_query($con,"update tblcategory set Is_Active='0' where id='$id'"); $msg="Category deleted "; } // Code for restore if($_GET['resid']) { $id=intval($_GET['resid']); $query=mysqli_query($con,"update tblcategory set Is_Active='1' where id='$id'"); $msg="Category restored successfully"; } // Code for Forever deletionparmdel if($_GET['action']=='parmdel' && $_GET['rid']) { $id=intval($_GET['rid']); $query=mysqli_query($con,"delete from  tblcategory  where id='$id'"); $delmsg="Category deleted forever"; } ?>

Update data into database php mysql

<?php session_start(); include('includes/config.php'); error_reporting(0); if(strlen($_SESSION['login'])==0)   {  header('location:index.php'); } else{ if(isset($_POST['submit'])) { $catid=intval($_GET['cid']); $category=$_POST['category']; $description=$_POST['description']; $query=mysqli_query($con,"Update  tblcategory set CategoryName='$category',Description='$description' where id='$catid'"); if($query) { $msg="Category Updated successfully "; } else{ $error="Something went wrong . Please try again.";     }  } ?>

Add data into database in php mysql

Adding data into database <?php session_start(); include('includes/config.php'); error_reporting(1); if(strlen($_SESSION['login'])==0)   {  header('location:index.php'); } else{ if(isset($_POST['submit'])) { $category=$_POST['category']; $description=$_POST['description']; $status=1; $query=mysqli_query($con,"Insert into tblcategory(CategoryName,Description,Is_Active)values('$category','$description','$status')");      if($query) { $msg="Category created"; } else{ $error="Something went wrong. Please try again.";     }  } ?>

User authentication in php

<?php  session_start(); //Database Configuration File include('includes/config.php'); //error_reporting(0); if(isset($_POST['login']))   {       // Getting username/ email and password      $uname=$_POST['username'];     $password=$_POST['password'];     // Fetch data from database on the basis of username/email and password $sql =mysqli_query($con,"SELECT AdminUserName,AdminEmailId,AdminPassword,UserType FROM tablename WHERE (AdminUserName='$uname' || AdminEmailId='$uname') && UserType='admin'");  $num=mysqli_fetch_array($sql); if($num>0) { $hashpassword=md5($password); // Hashed password fething from database //verifying Password if ($hashpassword==$num['AdminPassword'])  { $_SESSION['login']=$_POST['username'];     echo "<script type='text/javascript'> document.location = 'dashboard.php'; </script>";   } else { echo "<script>alert(&

Database connection in php

config.php  file content <?php define('DB_SERVER','localhost'); define('DB_USER','dbusername'); define('DB_PASS' ,'dbpassword'); define('DB_NAME','dbname'); $con = mysqli_connect(DB_SERVER,DB_USER,DB_PASS,DB_NAME); // Check connection if (mysqli_connect_errno()) {  echo "Failed to connect to MySQL: " . mysqli_connect_error(); } ?>