article

Thursday, October 17, 2019

Bootstrap Subscribe Newsletter Form inside Modal

Bootstrap Subscribe Newsletter Form inside Modal
<!DOCTYPE html>
<html>
<head> 
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Bootstrap Subscribe Newsletter Form inside Modal</title>
<link href="https://fonts.googleapis.com/css?family=Roboto|Varela+Round" rel="stylesheet">
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
<style type="text/css">
    body {
  font-family: 'Varela Round', sans-serif;
 } 
 .modal-newsletter { 
  color: #999;
  font-size: 15px;
 }
 .modal-newsletter .modal-content {
  padding: 40px;
  border-radius: 0;  
  border: none;
 }
 .modal-newsletter .modal-header {
  border-bottom: none;   
        position: relative;
  text-align: center;
  border-radius: 5px 5px 0 0;
 }
 .modal-newsletter h4 {
  color: #000;
  text-align: center;
  font-size: 30px;
  margin: 0 0 25px;
  font-weight: bold;
  text-transform: capitalize;
 }
 .modal-newsletter .close {
  background: #c0c3c8;
  position: absolute;
  top: -15px;
  right: -15px;
  color: #fff;
  text-shadow: none;
  opacity: 0.5;
  width: 22px;
  height: 22px;
  border-radius: 20px;
  font-size: 16px;
 }
 .modal-newsletter .close span {
  position: relative;
  top: -1px;
 }
 .modal-newsletter .close:hover {
  opacity: 0.8;
 }
 .modal-newsletter .form-control, .modal-newsletter .btn {
  min-height: 46px;
  border-radius: 3px; 
 }
 .modal-newsletter .form-control {
  box-shadow: none;
  border-color: #dbdbdb;
 }
 .modal-newsletter .form-control:focus {
  border-color: #19bc9c;
  box-shadow: 0 0 8px rgba(114, 101, 234, 0.5);
 }
    .modal-newsletter .btn {
        color: #fff;
        border-radius: 4px;
  background: #19bc9c;
  text-decoration: none;
  transition: all 0.4s;
        line-height: normal;
  padding: 6px 20px;
  min-width: 150px;
        border: none;
    }
 .modal-newsletter .btn:hover, .modal-newsletter .btn:focus {
  background: #4e3de4;
  outline: none;
 }
 .modal-newsletter .input-group {
  margin: 30px 0 15px;
 }
 .hint-text {
  margin: 100px auto;
  text-align: center;
 }
</style>
<script type="text/javascript">
 $(document).ready(function(){
  $("#myModal").modal('show');
 });
</script>
<div id="myModal" class="modal fade">
 <div class="modal-dialog modal-newsletter">
  <div class="modal-content">
   <form action="confirmation.php" method="post">
    <div class="modal-header">
     <button type="button" class="close" data-dismiss="modal" aria-hidden="true"><span>×</span></button>
    </div>
    <div class="modal-body text-center">
     <h4>Subscribe to our newsletter</h4> 
     <p>Sugnup for our weekly newsletter to get the latest news, updates and amazong offers delivered direcly in your inbox.</p>
     <div class="input-group">
      <input type="email" class="form-control" placeholder="Enter your email" required>
      <span class="input-group-btn">
       <input type="submit" class="btn btn-primary" value="Subscribe">
      </span>
     </div>
    </div>
   </form>   
  </div>
 </div>
</div>
<p class="hint-text"><strong>Note:</strong> Refresh the page or run the code to reload the modal.</p>
</body>
</html>

Thursday, September 26, 2019

Live Data Search using PHP MySqli and Jquery Ajax

Live Data Search using PHP MySqli and Jquery Ajax
<!DOCTYPE html>
<html>
<head> 
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Live Data Search using PHP MySqli and Jquery Ajax</title>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
 load_data();
  function load_data(query)
  {
   $.ajax({
    url:"ajaxlivesearch.php",
    method:"POST",
    data:{query:query},
    success:function(data)
    {
  $('#result').html(data);
    }
   });
  }
  $('#search_text').keyup(function(){
   var search = $(this).val();
   if(search != ''){
    load_data(search);
   }else{
    load_data();
   }
  });
});
</script>
</head>
<body>
<div class="container search-table">
<p><h2 align="center">Live Data Search using PHP MySqli and Jquery Ajax</h2></p>
            <div class="search-box">
                <div class="row">
                    <div class="col-md-3">
                        <h5>Search All Fields</h5>
                    </div>
                    <div class="col-md-9">
                        <input type="text" name="search_text" id="search_text" class="form-control" placeholder="Search all fields e.g. HTML">
                    </div> 
                </div>
            </div>
   <div id="result"></div>
</div>
<style>
.search-table{
    padding: 10%;
    margin-top: -6%;
}
.search-box{
    background: #c1c1c1;
    border: 1px solid #ababab;
    padding: 3%;
}
.search-box input:focus{
    box-shadow:none;
    border:2px solid #eeeeee;
}
.search-list{
    background: #fff;
    border: 1px solid #ababab;
    border-top: none;
}
.search-list h3{
    background: #eee;
    padding: 3%;color:#fe6f41;
    margin-bottom: 0%;
}
</style>
</body>
</html>
//ajaxlivesearch.php
<div class="search-list">
<?php
include"dbcon.php";
$output = '';
if(isset($_POST["query"]))
{
 $search = mysqli_real_escape_string($conn, $_POST["query"]);
 $query = "SELECT * FROM tblprogramming WHERE title LIKE '%".$search."%' OR category LIKE '%".$search."%'";
}else{
 $query = "SELECT * FROM tblprogramming ORDER BY id";
}
$result = mysqli_query($conn, $query);
if(mysqli_num_rows($result) > 0) {
 $totalfound = mysqli_num_rows($result);
  $output .= '<h3>'.$totalfound.' Records Found</h3>
  <table class="table table-striped custab">
  <thead>
      <tr>
         <th>Title</th>
         <th>Category</th>
      </tr>
  </thead>
  <tbody>';
 while($row = mysqli_fetch_array($result))
 {
  $output .= '
   <tr>
    <td>'.$row["title"].'</td>
    <td>'.$row["category"].'</td>
   </tr>';
 }
 echo $output;
}else{
 echo 'No Rocord Found';
}
?>
 </tbody>
   </table>
</div>
//dbcon.php
<?php
$conn = new mysqli('localhost','root','','testingdb');
if ($conn->connect_error) {
    die('Error : ('. $conn->connect_errno .') '. $conn->connect_error);
}
?>
//tablebase table tblprogramming
CREATE TABLE `tblprogramming` (
  `id` int(11) NOT NULL,
  `title` varchar(250) NOT NULL,
  `category` varchar(255) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

--
-- Dumping data for table `tblprogramming`
--

INSERT INTO `tblprogramming` (`id`, `title`, `category`) VALUES
(1, 'HTML', 'Web Development'),
(2, 'PHP', 'Web Development'),
(3, 'C#', 'Programming Language'),
(4, 'JavaScript', 'Web Development'),
(5, 'Bootstrap', 'Web Design'),
(6, 'Python', 'Programming Language'),
(7, 'Android', 'App Development'),
(8, 'Angular JS', 'Web Delopment'),
(9, 'Java', 'Programming Language'),
(10, 'Python Django', 'Web Development'),
(11, 'Codeigniter', 'Web Development'),
(12, 'Laravel', 'Web Development'),
(13, 'Wordpress', 'Web Development');

Wednesday, September 25, 2019

How to get the values of Select All Checkbox using jQuery

How to get the values of Select All Checkbox using jQuery <!DOCTYPE html> <html>
<head> 
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>How to get the values of Select All Checkbox using jQuery</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<SCRIPT language="javascript">
$(document).ready(function() {
 // add multiple select / deselect functionality
 $("#selectall").click(function () {
  $('.item').attr('checked', this.checked);
 });
 // if all checkbox are selected, check the selectall checkbox and viceversa
 $(".item").click(function(){
  if($(".item").length == $(".item:checked").length) {
   $("#selectall").attr("checked", "checked");
  } else {
   $("#selectall").removeAttr("checked");
  }
 });
 //get the values of selected checkboxes
 $("button").click(function(){
  var favorite = [];
  $.each($("input[name='programming']:checked"), function(){            
   favorite.push($(this).val());
  });
  alert("My favourite Programming are: " + favorite.join(", "));
    });
});
</SCRIPT>
</head>
<body>
<form>
<p><h1>How to get the values of Select All Checkbox using jQuery</h1></p>
<label>Select your favorite programming  <br/>
Select All Checkbox <input type="checkbox" id="selectall"/></label><br/>
<input type="checkbox" name="programming" class="item" value="Jquery"/>
Jquery<br/>
<input type="checkbox" name="programming" class="item" value="php mysql"/>
php mysql<br/>
<input type="checkbox" name="programming" class="item" value="3"/>
Java<br/>
<input type="checkbox" name="programming" class="item" value="4"/>
Javascript<br/>
<input type="checkbox" name="programming" class="item" value="5"/>
Python<br/>
<input type="checkbox" name="programming" class="item" value="6"/>
Ruby<br/>
<button type="button">Get Values</button>
</form>
</html>

Tuesday, September 24, 2019

Pagination with PHP and Mysqli

Pagination with PHP and Mysqli
<!DOCTYPE html>
<html>
<head> 
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Pagination with PHP and Mysqli</title>
</head>
<body>
<div align="center" style="font-size:24px;color:#cc0000;font-weight:bold">Pagination with PHP and Mysqli</div>
<div id="container">
<?php
$page = (isset($_GET['page']))?$_GET['page']:'';
if ($page==''){
 $page = "1";
}else{
 $page = $_GET['page'];
}
include"dbcon.php";
$cur_page = $page;
$page -= 1;
$per_page = 11; 
$previous_btn = true;
$next_btn = true;
$first_btn = true;
$last_btn = true;
$start = $page * $per_page;
$msg = "";
$query_pag_data = "SELECT * from country LIMIT $start, $per_page";
$result_pag_data = mysqli_query($conn, $query_pag_data);
while($row = mysqli_fetch_assoc($result_pag_data)) {
 $htmlmsg=htmlentities($row['country']); 
    $msg .= "<li><b>" . $row['id'] . "</b> " . $htmlmsg . "</li>";
}
$msg = "<div class='data'><ul>" . $msg . "</ul></div>"; // Content for Data

$query_pag_num = mysqli_query($conn,"SELECT COUNT(*) AS mycount FROM country" ) or die(mysqli_error($this->dblink));
$res = mysqli_fetch_object($query_pag_num);
$count = $res->mycount;
$no_of_paginations = ceil($count / $per_page);

// ---------------Calculating the starting and endign values for the loop----------------------------------- 
if ($cur_page >= 7) {
    $start_loop = $cur_page - 3;
    if ($no_of_paginations > $cur_page + 3)
        $end_loop = $cur_page + 3;
    else if ($cur_page <= $no_of_paginations && $cur_page > $no_of_paginations - 6) {
        $start_loop = $no_of_paginations - 6;
        $end_loop = $no_of_paginations;
    } else {
        $end_loop = $no_of_paginations;
    }
} else {
    $start_loop = 1;
    if ($no_of_paginations > 7)
        $end_loop = 7;
    else
        $end_loop = $no_of_paginations;
}
//----------------------------------------------------------------------------------------------------------- 
$msg .= "<div class='pagination'><ul>";

// FOR ENABLING THE FIRST BUTTON
if ($first_btn && $cur_page > 1) {
    $msg .= "<li p='1' class='active'><a href='?page=1'>First</a></li>";
} else if ($first_btn) {
    $msg .= "<li p='1' class='inactive'><a href='?page=1'>First</a></li>";
}
// FOR ENABLING THE PREVIOUS BUTTON
if ($previous_btn && $cur_page > 1) {
    $pre = $cur_page - 1;
    $msg .= "<li p='$pre' class='active'><a href='?page=$pre'>Previous</a></li>";
} else if ($previous_btn) {
    $msg .= "<li class='inactive'>Previous</li>";
}
for ($i = $start_loop; $i <= $end_loop; $i++) {
    if ($cur_page == $i)
        $msg .= "<li p='$i' style='color:#fff;background-color:#70BA4C;' class='active'><a href='?page=$i'>{$i}</a></li>";
    else
        $msg .= "<li p='$i' class='active'><a href='?page={$i}'>{$i}</a></li>";
}
// TO ENABLE THE NEXT BUTTON
if ($next_btn && $cur_page < $no_of_paginations) {
    $nex = $cur_page + 1;
    $msg .= "<li p='$nex' class='active'><a href='?page=$nex'>Next</a></li>";
} else if ($next_btn) {
    $msg .= "<li class='inactive'>Next</li>";
}
// TO ENABLE THE END BUTTON
if ($last_btn && $cur_page < $no_of_paginations) {
    $msg .= "<li p='$no_of_paginations' class='active'><a href='?page=$no_of_paginations'>Last</a></li>";
} else if ($last_btn) {
    $msg .= "<li p='$no_of_paginations' class='inactive'><a href='?page=$no_of_paginations'>Last</a></li>";
}
$total_string = "<span class='total' a='$no_of_paginations'>Page <b>" . $cur_page . "</b> of <b>$no_of_paginations</b></span>";
$msg = $msg . "</ul>" . $total_string . "</div>";  // Content for pagination 
echo $msg;
?>
</div>
<style type="text/css">
            body{
                width: 800px;
                margin: 0 auto;
                padding: 0;
            }
   a {text-decoration:none;}
   #container {margin-bottom:20px;}
   #container .data{
    list-style-type: none;
    margin: 0;
    padding: 0;
   }
            #container .data ul li{
                list-style: none;
                background-color:lightyellow;
    border:1px solid #FFDA5B;
    padding:10px;
    margin-bottom:5px;
            }
   #container .data ul li:hover{
                background-color:#70BA4C;
    border:1px solid #448B22;
            }
   #container .data ul li b {
                -moz-border-radius:12px;
    -webkit-border-radius:12px;
    border-radius:32px;
    background-color:#70BA4C;
    border:1px solid #448B22;
    color:#FFFFFF;padding:6px;margin-right:5px;
    text-shadow:1px 1px 0 green;
   }
            #container .pagination ul li.inactive,
            #container .pagination ul li.inactive:hover{
                background-color:#ededed;
                color:#bababa;
                border:1px solid #bababa;
                cursor: default;
            }
            #container .pagination{
                width: 800px;
                height: 25px;
            }
            #container .pagination ul li{
                list-style: none;
                float: left;
                border: 1px solid #006699;
                padding: 4px 8px 4px 8px;
                margin: 0 3px 0 3px;
                font-family: arial;
                font-size: 14px;
                color: #006699;
                font-weight: bold;
                background-color: #f2f2f2;
            }
            #container .pagination ul li:hover{
                color: #fff;
                background-color: #006699;
                cursor: pointer;
            }
   .total
   {
   float:right;font-family:arial;color:#999;
   }
</style>  
</body>
</html>
//dbcon.php
<?php
$conn = new mysqli('localhost','root','','testingdb');
if ($conn->connect_error) {
    die('Error : ('. $conn->connect_errno .') '. $conn->connect_error);
}
?>
Download SQL file Here

Wednesday, July 3, 2019

Java Swing jRadioButton Usage Tutorial


Java Swing jRadioButton Usage Tutorial
 
private void formWindowOpened(java.awt.event.ActionEvent evt)
  bgroup1.add(radiolicense);  
  bgroup1.add(radiolicense);
}

private void radiolicensePerformed(java.awt.event.ActionEvent evt) {
  cmdsubmit.setEnable(true);
}
private void radiolicensePerformed(java.awt.event.ActionEvent evt) {
  cmdsubmit.setEnable(false);
}
//=====================================
    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
        String qual = "";
        if (jRadioButton1.isSelected()){
            qual = "Your Under Graduate";
        }else{
            qual = "Graduate";
        }
        JOptionPane.showMessageDialog(rootPane, qual);
    }

Python GUI Tkinter Checkbutton Tutorial

Python GUI Tkinter Checkbutton Tutorial
 
from Tkinter import *
master = Tk()
master.geometry('250x200')

def var_states():
    print("Male : %d, \nFemale : %d" % (var1.get(), var2.get()))
def callbackFunc():
    if (chkValue.get()):
       tlabel = Label(master, text="Oh. I'm click value is {}".format(chkValue.get()))
       tlabel.pack()
    else:
       tlabel = Label(master, text="Oh. I'm Not clicked")
       tlabel.pack()
Label(master, text="Your sex:").grid(row=0, sticky=W)
var1 = IntVar()
Checkbutton(master, text="Male", variable=var1).grid(row=1, sticky=W)
var2 = IntVar()
Checkbutton(master, text="Female", variable=var2).grid(row=2, sticky=W)
Button(master, text="Quit", command=master.quit).grid(row=3, sticky=W, pady=4)
Button(master, text='Show', command=var_states).grid(row=4, sticky=W, pady=4)

chkValue = BooleanVar()
chkExample = Checkbutton(master, text="Check box", var=chkValue,command=callbackFunc)
chkExample.grid(column=10,row=10)
mainloop()

Tuesday, July 2, 2019

Python GUI Tkinter Button Tutorial

Python GUI Tkinter Button Tutorial
 
import Tkinter as tk

counter = 0
def counter_label(lable):
    counter = 0
    def count():
    global counter
    counter +=1
    label.config(text=str(counter))
    label.after(1000,count)
    count()
  
root = tk.Tk()
root.title("Counting Seconds")
label = tk.Label(root, fg="dark green")
label.pack()
counter_label(label)
button = tk.Button(root, text="Stop", width=25, command=root.destroy)
button.pack()
root.mainloop()
 
import Tkinter
import tkMessageBox

top = Tkinter.Tk()

def helloCallBack():
    tkMessageBox.showinfo("hello Python","Hello word")
B = Tkinter.Button(top,text="Hello button",command=helloCallBack)
B.pack()
top.mainloop();
 
from tkinter import *
from tkinter import messagebox 
top = Tk()  
top.geometry("300x200") 
top.title('Hello Python')

def red():  
    messagebox.showerror("Hello", "Red Button clicked") 
def blue():  
    messagebox.showinfo("Hello", "Blue Button clicked") 
def green():  
    messagebox.showinfo("Hello", "Green Button clicked") 
def clicked():
    res = "Welcome to " + txt.get()
    lbl.configure(text= res)
b1 = Button(top,text = "Red",command = red,activeforeground = "red",activebackground = "pink",bg="green",font="14",pady=10) 
b2 = Button(top, text = "Blue",command = blue,activeforeground = "blue",activebackground = "pink",pady=10)  
b3 = Button(top, text = "Green",command = green,activeforeground = "green",activebackground = "pink",pady = 10)  
b4 = Button(top, text = "Yellow",command = clicked,activeforeground = "yellow",activebackground = "pink",pady = 10) 
lbl = Label(top,text = "Hello",font="14") 
txt = Entry(top,width=50)
b1.pack(side = LEFT) 
b2.pack(side = RIGHT)  
b3.pack(side = TOP)  
b4.pack(side = BOTTOM)  
lbl.pack()  
txt.pack(side = TOP)
top.mainloop() 

Java Swing JPasswordField & JCheckBox Usage - Login Example Tutorial

Java Swing JPasswordField & JCheckBox Usage - Login Example Tutorial
 
private void cmdloginActionPerformed(java.awt.event.ActionEvent evt) {                                         
        if (txtusername.getText().equalsIgnoreCase("test") && txtpass.getText().equalsIgnoreCase("123")){
            if (chkremember.isSelected()){
                lblmessage.setText("Login successful with remembering option");
            }else{
                lblmessage.setText("Login successful without remembering option");
            }
        }else{
            lblmessage.setText("Login Failed");
        } 
    }
private void cmdloginActionPerformed(java.awt.event.ActionEvent evt) {                                         
        // TODO add your handling code here:
        String userName =  txtusername.getText();
        String password =  txtpass.getText();
        if (userName.trim().equals("admin") && password.trim().equals("admin")) {
            lblmessage.setText("Hello" + userName +"");
        }else{
            lblmessage.setText("Invalid User");
        }
    }                                        

    private void cmdresetActionPerformed(java.awt.event.ActionEvent evt) {                                         
        // TODO add your handling code here:
         lblmessage.setText("");
         txtusername.setText("");
         txtpass.setText("");
    } 

Monday, July 1, 2019

Java Swing Tutorial JTextField Usage Using Netbeans IDE

Java Swing Tutorial JTextField Usage Using Netbeans IDE
 
private void cmdsubmitActionPerformed(java.awt.event.ActionEvent evt) {
  String message = "Hello,"+txtname.getText();
  lblmessagedisplay.setText(message);
}

private void cmdsubmitActionPerformed(java.awt.event.ActionEvent evt) {
    int a=Integer.parseInt(x);
 String y=(String) jComboBox1.getSelectedItem();
 int b=Integer.parseInt(y);
 int r=a*b;
 String z=Integer.toString(r);
 txtresult.setText(z);
}

private void cmdsubmitActionPerformed(java.awt.event.ActionEvent evt) {
 String s1=tf1.getText();
 String s2=tf2.getText();
 int a=Integer.parseInt(s1);
 int b=Integer.parseInt(s2);
 int c=0;
 c=a+b;
 String result=String.valueOf(c);
 tf3.setText(result);
}

Sunday, June 30, 2019

Java Swing if else statement using Netbeans IDE

Java Swing if else statement using Netbeans IDE
 
public static void main(String args[]) {
 String input = JOptionPane.showInputDialog("Enter your age");
 int aga = Integer.parseInt(input);
 if (age >=18){
   JOptionPane.showMessageDialog(null,"You are an adult");
 }else{
   JOptionPane.showMessageDialog(null,"You are a minor");
 }
 /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new JTextField_JFrame().setVisible(true);
            }
        });
}
 
public static void main(String args[]) {
 int side1 = Integer.parseInt(JOptionPane.showInputDialog("Enter the first side"));
 int side2 = Integer.parseInt(JOptionPane.showInputDialog("Enter the second side"));
 int side3 = Integer.parseInt(JOptionPane.showInputDialog("Enter the third side"));

 if (side1 == side2 && side2 == side3){
    JOptionPane.showMessageDialog(null,"It is an equilateral triangle");
 }else{
   if (side1 == side2 || side2 == side3) {
   JOptionPane.showMessageDialog(null,"It is an isosceles triagle")
   }else{
   JOptionPane.showMessageDialog(null,"It is an scalene triagle")
   }
 }
 
 /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new JTextField_JFrame().setVisible(true);
            }
        });
}

How to create simple Java Swing GUI with Netbeans IDE

How to create simple Java Swing GUI with Netbeans IDE


 
    private void cmdsubmitbuttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmdsubmitbuttonActionPerformed
        // TODO add your handling code here:
        String name = JOptionPane.showInputDialog("Type your name please");
        JOptionPane.showMessageDialog(null, "Hello " + name);
        //JOptionPane.showMessageDialog(null, "Hello World");
    }//GEN-LAST:event_cmdsubmitbuttonActionPerformed

Friday, June 28, 2019

How to Download Install NetBeans IDE 8.0.2 and create a project and run simple program

How to Download Install NetBeans IDE 8.0.2 and create a project and run simple program

Tutorial.java


  
package tutorial;
public class Tutorial {
    public static void main(String[] args) {
        // TODO code application logic here simple program that will just print out the numbers 1 to 5
        for (int i = 1; i < 6; i++)
        {
          System.out.println(i);
        }
        
        Person p = new Person("Mike");
        p.displayName();
    }
    
}

Person.java

  
package tutorial;
public class Person {
    private String name;
    /** Create a new instance of person */
    public Person(String n)
    {
      name = n;
    }
    //display the name
    public void displayName()
    {
      System.out.println(name);
    }
    
}

Wednesday, March 20, 2019

Installing laravel 5.2 version with Registration, Login, Password Reset and Dashboard

Installing laravel 5.2 version with Registration, Login, Password Reset and Dashboard

open cmd and navigate folder

C:\xampp\htdocs>composer create-project laravel/laravel laravel_5_2 "5.2.*"

C:\xampp\htdocs\laravel_5_2>php artisan make:auth

setup database C:\xampp\htdocs\laravel\.env
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=laravel_dev
DB_USERNAME=root

DB_PASSWORD=''

C:\xampp\htdocs\laravel_5_2>php artisan migrate

Navigate url http://localhost/phpmyadmin/ check the new table created
users and password_resets table


Navigate url http://localhost/laravel_5_2/public




Tuesday, February 19, 2019

How to create wordpres plugins custom admin menu

How to create wordpres plugins custom admin menu

1. first create folder wp-content\plugins\admin_menu
2. create php file admin.php

Code
<?php
/**
* Plugin Name: Admin Menu
* Plugin URI: https://tutorial101.blogspot.com/
* Description: A custom admin menu.
* Version: 1.0
* Author: Cairocoders
* Author URI: http://tutorial101.blogspot.com/
**/
function theme_options_panel(){
  add_menu_page('Theme page title', 'Theme menu', 'manage_options', 'theme-options', 'wps_theme_func');
  add_submenu_page('theme-options', 'Settings page title', 'Settings menu label', 'manage_options', 'theme-op-settings', 'wps_theme_func_settings');
  add_submenu_page('theme-options', 'FAQ page title', 'FAQ menu label', 'manage_options', 'theme-op-faq', 'wps_theme_func_faq');
}
add_action('admin_menu', 'theme_options_panel');
//function
function wps_theme_func(){
        echo '<div class="wrap"><div id="icon-options-general" class="icon32"><br></div>
        <h2>Theme</h2></div>';
}
function wps_theme_func_settings(){
        echo '<div class="wrap"><div id="icon-options-general" class="icon32"><br></div>
        <h2>Settings</h2></div>';
}
function wps_theme_func_faq(){
        echo '<div class="wrap"><div id="icon-options-general" class="icon32"><br></div>
        <h2>FAQ</h2></div>';
}

Tuesday, February 5, 2019

How to create WordPress plugins with Shortcode Ajax

How to create WordPress plugins with Shortcode Ajax

1. Create folder name wp-content\plugins\"myplugins_shortcode_ajax"
2. Add index.php file wp-content\plugins\myplugins_shortcode_ajax\index.php
3. Add code index.php
//index.php
<?php
/**
* Plugin Name: Shortcode ajax
* Plugin URI: https://tutorial101.blogspot.com/
* Description: How to add a form to a shortcode in WordPress (using PHP and Ajax)
* Version: 1.0
* Author: Cairocoders
* Author URI: http://tutorial101.blogspot.com/
**/
$ajaxpostExample = new ajaxpostExample(); 
class ajaxpostExample {
 public function __construct() {
        $this->attach_actions();
  $this->attach_shortcodes();
    }
 function attach_actions() {
        add_action('wp_ajax_nopriv_ajax_do_something', array($this, 'do_something_serverside'));
        add_action('wp_ajax_ajax_do_something', array($this, 'do_something_serverside')); /* notice green_do_something appended to action name of wp_ajax_ */
        add_action('wp_enqueue_scripts', array($this, 'theme_enqueue_styles'), 99999);
    }
 function theme_enqueue_styles() {
        //include the js
  wp_enqueue_script('ajaxsample_script', plugin_dir_url(__FILE__) . 'js/ajax_call_to_handle_form_submit.js', array('jquery'));
  wp_enqueue_style('handlecss',  plugin_dir_url(__FILE__) . 'css/ajaxshortcodestyle.css');
  // in JavaScript, object properties are accessed as ajax_object.ajax_url, ajax_object.we_value
  // Register the script
  //wp_localize_script( $handle, $name, $data );
  wp_localize_script('ajaxsample_script', 'ajax_object', array('ajax_url' => admin_url('admin-ajax.php'), 'we_value' => 1234));
 }
 function do_something_serverside() {
  global $wpdb;
  // output to ajax call   
  $txtname = $_POST['txtname'];
  $txtemail = $_POST['txtemail'];
  $txtsubject = $_POST['txtsubject'];
  $txtmessage = $_POST['txtmessage'];
  if ($txtname=='' OR $txtemail==''){
   echo "false"; 
  }else{ 
   echo "true";
  }
  //insert to a custom database table
  $wpdb->insert("test", array(
   "contactname" => $txtname
  ));
        die();
    }
 function attach_shortcodes() {
        add_shortcode('shortcode_ajax_form', array($this, 'shortcode_with_form_code')); //<p>[shortcode_ajax_form]</p>
    }
    function shortcode_with_form_code($atts, $content = null) {
        if ($this->formOk()) {
            return " <div>thanks your form has been submitted</div>";
        } else {
            return $this->show_form();
        }
    }
 function show_form() {
        $form = '<div class="well"><div id="display_rec"></div>
        <form id="green_form" action="">
          Name:<br>
          <input type="text" name="txtname" class="form-control" value="">
          <br>
          Email Address:<br>
          <input type="text" name="txtemail" class="form-control" value="">
    <br>
          Subject:<br>
          <input type="text" name="txtsubject" class="form-control" value="">
    <br>
          Message:<br>
          <textarea name="txtmessage" class="form-control" rows="5" cols="25" required="required" placeholder="Message"></textarea>
          <br>
          <br>
          <input type="submit" class="btn-primary" value="Submit" >
        </form></div>';
        return $form;
    }
 function formOk(){
        return false; 
    }
} 
4. Create folder name for js file wp-content\plugins\myplugins_shortcode_ajax\js\ajax_call_to_handle_form_submit.js then add this code
jQuery( document ).ready(function() {
    // Handler for .ready() called.
    //
    jQuery(function(){
  jQuery("#green_form").submit(function(event){
   event.preventDefault();
            var formOk = true;
            // do js validation 
   jQuery.ajax({
    url:ajax_object.ajax_url,
                type:'POST',
                data: jQuery(this).serialize() + "&action=ajax_do_something", //wp_ajax_nopriv_ajax_do_something, wp_ajax_ajax_do_something
    success:function(response){ 
     if(response=="true"){
                       //alert('success'); 
        jQuery("#display_rec").html("<div class='success'><p>Message Success Sent</p></div>")
                    }else{
                        jQuery("#display_rec").html("<div class='fail'>Please input required fields.</div>")
                        //alert('Please input required fields.'); 
                    } 
                }
   });
  }); 
    });
});
5. css code wp-content\plugins\myplugins_shortcode_ajax\css\ajaxshortcodestyle.css
.form-control {
    display: block;
    width: 100%;
    height: 34px;
    padding: 6px 12px;
    font-size: 14px;
    line-height: 1.428571429;
    color: #555;
    background-color: #fff;
    background-image: none;
    border: 1px solid #ccc;
    border-radius: 4px;
    transition: border-color ease-in-out .15s,box-shadow ease-in-out .15s;
}
.btn-primary {
    color: #fff;
    background-color: #428bca;
    border-color: #357ebd;
}
.well {
    padding: 19px;
    margin-bottom: 20px;
    background-color: #428bca;
    border: 1px solid #357ebd;color:#fff;
    border-radius: 4px;
    -webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,.05);
    box-shadow: inset 0 1px 1px rgba(0,0,0,.05);
}
.success, .fail, .information, .attention {
 background-repeat: no-repeat;
 background-position: 10px center;
 height: 40px;
 font-size: 11px;
 line-height: 22px;
 margin-bottom: 20px;
 padding-top: 10px;
 padding-right: 10px;
 padding-bottom: 10px;
 padding-left: 50px;
 
}
/* Succes Notification Box */
.success     {
 background-color: #EBF8D6;
 border: 1px solid #A6DD88;
 color: #539B2D;
 background-image: url(../images/accept00.png);
}
/* Failure Notification Box */
.fail      {
 background-color: #FFECE6;
 border: 1px solid #FF936F;
 color: #842100;
 background-image: url(../images/delete00.png);
}
/* Information Notification Box */
.information    {
 background-color: #D3EEF1;
 border: 1px solid #81CDD8;
 color: #369CAB;
 background-image: url(../images/info0000.png);
}
/* Attention Notification Box */
.attention   {
 background-color: #FFFBCC;
 border: 1px solid #FFF35E;
 color: #C69E00;
 background-image: url(../images/warning0.png);
}
6. Shortcode [shortcode_ajax_form]

Monday, February 4, 2019

How to create wodpress plugins and shortcodes 11 example from simple to complex

How to create wodpress plugins and shortcodes 11 example from simple to complex

List of tutorial
1. How to create contact form with submit mail
2. How to insert record post database table
3. How to insert shortcode google ads
4. How to list recent post
5. How to list recent post in shortcode parameters
6. How to list recent post in content shortcode
7. How to enabling shortcodes in widgets
8. Display wordpress menu in shortcode
9. How to insert A Google Maps shortcode
10. How to embed pdf
11. How to Displaying database table data in shortcodes

A standard header is introduced below to establish your plugin’s presence.
<?php
/**
* Plugin Name: My Plugin Name
* Plugin URI: http://mypluginuri.com/
* Description: A brief description about your plugin.
* Version: 1.0 or whatever version of the plugin (pretty self explanatory)
* Author: Plugin Author's Name
* Author URI: Author's website
* License: A "Slug" license name e.g. GPL12
*/
Create folder under plugins folder wp-content\plugins\myplugins_with_shortcode folder name myplugins_with_shortcode and create php file index.php file
2. Add the code below wp-content\plugins\myplugins_with_shortcode\index.php
<?php
/**
* Plugin Name: Custom Plugins with shortcode
* Plugin URI: https://tutorial101.blogspot.com/
* Description: A custom plugin and shortcode for example.
* Version: 1.0
* Author: Cairocoders
* Author URI: http://tutorial101.blogspot.com/
**/
//first example how to create contact form with submit mail
function form_creation(){
 //add submit 
 if (isset( $_POST['cmdsubmit'])) {
        $txtname = $_POST['txtname'];
        $txtemail = $_POST['txtemail'];
        $message = $_POST['message'];
  $msg = "Name: $txtname <br/>Email: $txtemail <br/>Message: $message <br/>";
    // send email
  mail("someone@example.com","My subject",$msg);
    }
 $form .= '<div class="well"><p><h5>Simple Contact Form</h5></p><form method = "post">
 Name: <input type="text" name="txtname" class="form-control"><br>
 Email: <input type="email" name="txtemail" class="form-control"><br>
 Message: <textarea name="message" class="form-control"> Enter text here…</textarea><br/>
 <input type="submit" name="cmdsubmit"> '.$msg.'
 </form></div>';
 return "$form";
}
add_shortcode("testform", "form_creation"); //add code //<p>[testform]</p>
//add css file
function wpse_89494_enqueue_scripts() {
 wp_enqueue_style('handlecss',  plugin_dir_url(__FILE__) . 'css/ajaxshortcodestyle.css');
}
//second example how to insert to post
function input_fields( $atts ) {
 //add submit
 if ( isset( $_POST['gg'] ) ) {
        $post = array(
            'post_content' => $_POST['content'], 
   'post_status' => 'publish',
            'post_title'   => $_POST['title']
        );
  // Insert the post into the database
        wp_insert_post($post); //https://developer.wordpress.org/reference/functions/wp_insert_post/
    }
    $formpost .= '<form method = "post">
        Post title : <input type="text" name="title"><br/>
        Post Contents : <input type="text" name="content"></br/>
        <input type="submit" name="gg">
    </form>';
 return "$formpost";
}
add_shortcode( 'add_fields', 'input_fields' );
//third example shortcode google ads
function get_adsense($atts) {
    return '<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- WordPress hosting -->
<ins class="adsbygoogle"
     style="display:inline-block;width:728px;height:90px"
     data-ad-client="ca-pub-0327511395451286"
     data-ad-slot="6566424785"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>';
}
add_shortcode('adsense', 'get_adsense');
//4th example how to list recent post
function recent_posts_function() {
   query_posts(array('orderby' => 'date', 'order' => 'DESC' , 'showposts' => 1));
   if (have_posts()) :
      while (have_posts()) : the_post();
         $return_string = '<a href="'.get_permalink().'">'.get_the_title().'</a>';
      endwhile;
   endif;
   wp_reset_query();
   return $return_string;
}
add_shortcode('recent_posts', 'recent_posts_function');
//5 example SHORTCODE PARAMETERS
function recent_posts_function2($atts){
   extract(shortcode_atts(array(
      'posts' => 1,
   ), $atts));
   $return_string = '<ul>';
   query_posts(array('orderby' => 'date', 'order' => 'DESC' , 'showposts' => $posts));
   if (have_posts()) :
      while (have_posts()) : the_post();
         $return_string .= '<li><a href="'.get_permalink().'">'.get_the_title().'</a></li>';
      endwhile;
   endif;
   $return_string .= '</ul>';
   wp_reset_query();
   return $return_string;
}
add_shortcode('recent_posts2', 'recent_posts_function2'); 
//6 example CONTENT IN SHORTCODE [recent-posts posts="5"]This is the list heading[/recent-posts]
function recent_posts_function3($atts, $content = null) {
   extract(shortcode_atts(array(
      'posts' => 1,
   ), $atts));
   $return_string = '<h3>'.$content.'</h3>';
   $return_string .= '<ul>';
   query_posts(array('orderby' => 'date', 'order' => 'DESC' , 'showposts' => $posts));
   if (have_posts()) :
      while (have_posts()) : the_post();
         $return_string .= '<li><a href="'.get_permalink().'">'.get_the_title().'</a></li>';
      endwhile;
   endif;
   $return_string .= '</ul>';
   wp_reset_query();
   return $return_string;
}
add_shortcode('recent_posts3', 'recent_posts_function3');
//7 example ENABLING SHORTCODES IN WIDGETS
add_filter('widget_text', 'do_shortcode');

//8 example WORDPRESS MENU
function menu_function($atts, $content = null) {
   extract(
      shortcode_atts(
         array( 'name' => null, ),
         $atts
      )
   );
   return wp_nav_menu(
      array(
          'menu' => $name,
          'echo' => false
          )
   );
}
add_shortcode('menu', 'menu_function');
//9 example A Google Maps shortcode
function googlemap_function($atts, $content = null) {
   extract(shortcode_atts(array(
      "width" => '640',
      "height" => '480',
      "src" => ’
   ), $atts));
   return '<iframe width="'.$width.'" height="'.$height.'" src="'.$src.'&output=embed" ></iframe>';
}
add_shortcode("googlemap", "googlemap_function");

//10 example PDF EMBEDDING
function pdf_function($attr, $url) {
   extract(shortcode_atts(array(
       'width' => '640',
       'height' => '480'
   ), $attr));
   return '<iframe src="http://docs.google.com/viewer?url=' . $url . '&embedded=true" style="width:' .$width. '; height:' .$height. ';">Your browser does not support iframes</iframe>';
}
add_shortcode('pdf', 'pdf_function'); 
// last 11 example Displaying database table data in shortcodes
function listpost_func()
{
 global $wpdb;
    $postshow .= '<div class="recent-posts">';
 $sql_post = $wpdb->get_results("SELECT * FROM wp_posts WHERE post_status='publish'");
 foreach ($sql_post as $rows_post) 
 {
  $post_title = $rows_post->post_title;  
   $postshow .= '<h6>'.$post_title.'</h6>';
 }
    $postshow .= '</div>';
 return "$postshow";
}
add_shortcode( 'listpost', 'listpost_func' ); 
css code wp-content\plugins\myplugins_with_shortcode\css\ajaxshortcodestyle.css
.form-control {
    display: block;
    width: 100%;
    height: 34px;
    padding: 6px 12px;
    font-size: 14px;
    line-height: 1.428571429;
    color: #555;
    background-color: #fff;
    background-image: none;
    border: 1px solid #ccc;
    border-radius: 4px;
    transition: border-color ease-in-out .15s,box-shadow ease-in-out .15s;
}
.btn-primary {
    color: #fff;
    background-color: #428bca;
    border-color: #357ebd;
}
.well {
    padding: 19px;
    margin-bottom: 20px;
    background-color: #428bca;
    border: 1px solid #357ebd;color:#fff;
    border-radius: 4px;
    -webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,.05);
    box-shadow: inset 0 1px 1px rgba(0,0,0,.05);
}

Thursday, January 31, 2019

How To Create A WordPress Plugin

How To Create A WordPress Plugin

A plugin must contain a bit of meta information which tells WordPress what it is and how to handle it within your website.

A standard header is introduced below to establish your plugin’s presence.



<?php
/**
* Plugin Name: My Plugin Name
* Plugin URI: http://mypluginuri.com/
* Description: A brief description about your plugin.
* Version: 1.0 or whatever version of the plugin (pretty self explanatory)
* Author: Plugin Author's Name
* Author URI: Author's website
* License: A "Slug" license name e.g. GPL12
*/

1 Create folder under plugins folder  wp-content\plugins\myplugins folder name myplugins and create index.php file

2. Add the code below

<?php
/**
* Plugin Name: Custom Music Reviews
* Plugin URI: https://tutorial101.blogspot.com/
* Description: A custom music review plugin built for example.
* Version: 1.0
* Author: Cairocoders
* Author URI: http://tutorial101.blogspot.com/
**/

// Register the Custom Music Review Post Type
function register_cpt_music_review() {
    $labels = array(
        'name' => _x( 'Music Reviews', 'music_review' ), //post type is called music_review url https://codex.wordpress.org/Post_Types
        'singular_name' => _x( 'Music Review', 'music_review' ), 
        'add_new' => _x( 'Add New', 'music_review' ), //and new link wp-admin/post-new.php?post_type=music_review
        'add_new_item' => _x( 'Add New Music Review', 'music_review' ),
        'edit_item' => _x( 'Edit Music Review', 'music_review' ),
        'new_item' => _x( 'New Music Review', 'music_review' ),
        'view_item' => _x( 'View Music Review', 'music_review' ),
        'search_items' => _x( 'Search Music Reviews', 'music_review' ),
        'not_found' => _x( 'No music reviews found', 'music_review' ),
        'not_found_in_trash' => _x( 'No music reviews found in Trash', 'music_review' ),
        'parent_item_colon' => _x( 'Parent Music Review:', 'music_review' ),
        'menu_name' => _x( 'Music Reviews', 'music_review' ), //left side menu edit.php?post_type=music_review
    );
 
    $args = array(
        'labels' => $labels,
        'hierarchical' => true,
        'description' => 'Music reviews filterable by genre',
        'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'trackbacks', 'custom-fields', 'comments', 'revisions', 'page-attributes' ),
        'taxonomies' => array( 'genres' ),
        'public' => true,
        'show_ui' => true,
        'show_in_menu' => true,
        'menu_position' => 5,
        'menu_icon' => 'dashicons-format-audio',
        'show_in_nav_menus' => true,
        'publicly_queryable' => true,
        'exclude_from_search' => false,
        'has_archive' => true,
        'query_var' => true,
        'can_export' => true,
        'rewrite' => true,
        'capability_type' => 'post'
    );
 
    register_post_type( 'music_review', $args );
} 
add_action( 'init', 'register_cpt_music_review' );

//custom taxonomies to extend themes or plugins 
//Register a new Taxonomy using register_taxonomy() 
function genres_taxonomy() { //taxonomy is a way to group things together.
    register_taxonomy( //https://codex.wordpress.org/Taxonomies
        'genres', //new taxonomy called genres
        'music_review', //and assigns it to our post type music_review
        array(
            'hierarchical' => true,
            'label' => 'Genres', //edit-tags.php?taxonomy=genres&post_type=music_review
            'query_var' => true,
            'rewrite' => array(
                'slug' => 'genre',
                'with_front' => false
            )
        )
    );
}
add_action( 'init', 'genres_taxonomy');


// Function used to automatically create Music Reviews page.
function create_music_review_pages()
  {
   //post status and options
    $post = array(
          'comment_status' => 'open',
          'ping_status' =>  'closed' ,
          'post_date' => date('Y-m-d H:i:s'),
          'post_name' => 'music_review',
          'post_status' => 'publish' ,
          'post_title' => 'Music Reviews',
          'post_type' => 'page',
    );
    //insert page and save the id
    $newvalue = wp_insert_post( $post, false );
    //save the id in the database
    update_option( 'mrpage', $newvalue );
  }
// Activates function if plugin is activated
register_activation_hook( __FILE__, 'create_music_review_pages');

//Testing
//first create a new page called "Music Reviews" http://localhost/wordpress/music_review/
//Lets create an example music review and see what outputs.

Saturday, December 15, 2018

Create A CSS Administrator Login Form Design

Create A CSS Administrator Login Form Design

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Create A CSS Administrator Login Form Design and Login system using PHP with MYSQL database</title>
<style>
#login-form {
	margin:106px auto 0px auto;
	width:560px;
	border:solid 12px #E0E0E0;
	background:#E0E0E0;
	border-radius:12px;
	-moz-border-radius:12px;
	webkit-border-radius:12px;
}
#login-form{
border-color:#4BB2C5;
}
#login-inner {
	border-radius:5px;
	-moz-border-radius:5px;
	webkit-border-radius:5px;
	margin:0 auto;
	padding:30px;
	width:500px;
}
#login-form #wrapper{
	height: 50px;
	border-radius: 8px;
	-moz-border-radius: 8px;
	-webkit-border-radius: 8px;
	text-align:center;
	width:494px;
	margin:0px auto 30px auto;
	font-size:1.2em;
	background-image: url('img/bg.jpg');
}
#login-form #wrapper p{
	padding-top:4px;
	margin:0;
	text-transform:uppercase;
	letter-spacing:2px;
	line-height:2.2em;
	color:#FFF;
	font-weight:bold;
	text-shadow:#111 0px 1px 1px;
}
.field-separator{
	width:560px;
	margin:0px auto 20px auto;
}
#login-form label{
	color:#111;
	display:block;
	font-size:1em;
	margin-bottom:2px;
	font-weight:bold
}
#login-form input.txt {
	background:url('img/login_input_bg.png') repeat-x scroll left top #F7FCFF;
	border:1px solid #CCC;
	color:#25313C;
	font-size:1.4em;
	width:486px;
	padding:4px;
}
#login-form input#login-button{
	text-transform:uppercase;
	float:right;
	margin-top:10px;
	color:#DDD;
}
div#remember-me{
	float:left;
	width:300px;
	margin-top:16px;
}
div#remember-me a{
	color:#000;
	padding-right:10px;
	font-weight:bold;
	font-size:0.75em;
}
#login-bottom{
border-top: 2px dotted #BBB;
padding: 3px;
}
input.submit {
background-color: #111;
}
.submit::selection {
background: transparent;
}
input.submit.large {
padding: 8px 14px 9px;
font-size: 14px;
}
input.submit.round {
border:5px;
border-radius:5px;
-moz-border-radius:5px;
webkit-border-radius:5px;
}
</style>
</head> 
<body style="background:#FEFEFE url('img/bg.jpg') repeat-x;">
<form action="loginsubmit.php" method="post" id="login-form">
     <div id="login-inner">
         <div id="wrapper">
             <p>Administration Login</p>
         </div>
         <div class="field-separator">
             <label for="login">Login</label>
             <input type="text" name="login" value="" id="login" class="txt" />
         </div>
         <div class="field-separator">
             <label for="password">Password</label>
             <input type="password" name="password" value="" id="password" class="txt" />
         </div>
         <div id="login-bottom">
              <div id="remember-me">
                 <a href="#">Remember Me</a>|
                 <a href="#">Forgot Password</a>
			  </div>
             <input type="submit" name="enter" value="Enter" class="submit large round" id="login-button" />
             <div style="clear: both"></div>
         </div>
     </div>
</form>
</body>
</html>
//loginsubmit.php
<?php
$conn = new mysqli('localhost','root','','testingdb');
if ($conn->connect_error) {
    die('Error : ('. $conn->connect_errno .') '. $conn->connect_error);
}
$username = $_POST['login'];
$pass = $_POST['password'];
$sqlc="SELECT * FROM users WHERE username = '$username' AND password = '$pass'";
if ($rsdc=mysqli_query($conn,$sqlc)){
	$total=mysqli_num_rows($rsdc);
	  if ($total == '1') {
		  echo'<h1>You are a validated user.</h1>';
	  }else{
		echo'<h1>Sorry, your credentials are not valid, Please try again.</h1>';	
	  }		
}	
?>

Sunday, December 9, 2018

Create a Tabbed Content With jQuery And CSS

Create a Tabbed Content With jQuery And CSS
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Create a Tabbed Content With jQuery And CSS</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.min.js"></script>
<script>
$(document).ready(function(){
 $("a.tab").click(function () {
  $(".active").removeClass("active");
  $(this).addClass("active");
  $(".content").slideUp();
  var content_show = $(this).attr("title");
  $("#"+content_show).slideDown();
  return false
 });
});
</script>
</head>
<body>
<div id="tabbed_box_1">
 <div class="tabbed_area">
	<ul class="tabs">
         <li><a href="#" title="content_1" class="tab active">Popular</a></li>
         <li><a href="#" title="content_2" class="tab">Latest</a></li>
         <li><a href="#" title="content_3" class="tab">Comments</a></li>
     </ul>
     <div id="content_1" class="content">
      <ul>
          <li><a href="">Testing The Elements <small>January 11, 2010</small></a></li>
          <li><a href="">Testing Some Boxes <small>January 11, 2010</small></a></li>
          <li><a href="">Image in a post<small>January 11, 2010</small></a></li>
          <li><a href="">Sed tincidunt augue et nibh <small>November 11, 2011</small></a></li>
          <li><a href="">Morbi rhoncus arcu egestas erat <small>December 11, 2011</small></a></li>
          <li><a href="">Web Development <small>December 18, 2011</small></a></li>
		</ul>
     </div>
	 <div id="content_2" class="content">
      <ul>
          <li><a href="">Image in a post <small>January 11, 2010</small></a></li>
          <li><a href="">Testing The Elements<small>January 11, 2010</small></a></li>
          <li><a href="">Testing Some Boxes<small>January 11, 2010</small></a></li>
          <li><a href="">Lobortis tellus diam <small>January 11, 2010</small></a></li>
          <li><a href="">This is another featured post<small>January 7, 2011</small></a></li>
          <li><a href="">Testing The Elements<small>January 20, 2011</small></a></li>
		</ul>
     </div>
	 <div id="content_3" class="content">
      <ul>
          <li><a href="">admin: Looks like the Old Course at St. Andrews!...</a></li>
          <li><a href="">admin: Very nice boxes!...</a></li>
          <li><a href="">admin: And another threaded reply!...</a></li>
          <li><a href="">admin: This is a threaded reply!...</a></li>
          <li><a href="">admin: And this is a third comment with some lorem ipsum!...</a></li>
		</ul>
     </div>
 </div>
</div> 

<style>
body {
background-position:top center;
background-color:#EBE9E1;
margin:40px;
}
#tabbed_box_1 {
margin: 0px auto 0px auto;
width:300px;
}
.tabbed_area {
	border:2px solid #E6E6E6;
	background-color:#F5F4F0;
	padding:8px;
	border-radius: 8px; /*w3c border radius*/
	box-shadow: 3px 3px 4px rgba(0,0,0,.5); /* w3c box shadow */
	-moz-border-radius: 8px; /* mozilla border radius */
	-moz-box-shadow: 3px 3px 4px rgba(0,0,0,.5); /* mozilla box shadow */
	background: -moz-linear-gradient(center top, #a4ccec, #72a6d4 25%, #3282c2 45%, #357cbd 85%, #72a6d4); /* mozilla gradient background */
	-webkit-border-radius: 8px; /* webkit border radius */
	-webkit-box-shadow: 3px 3px 4px rgba(0,0,0,.5); /* webkit box shadow */
	background: -webkit-gradient(linear, center top, center bottom, from(#a4ccec), color-stop(25%, #72a6d4), color-stop(45%, #3282c2), color-stop(85%, #357cbd), to(#72a6d4)); /* webkit gradient background */
}
ul.tabs {
margin:0px; padding:0px;
margin-top:5px;
margin-bottom:6px;
}
ul.tabs li {
list-style:none;
display:inline;
}
ul.tabs li a {
	background-color:#EBE9E1;
	color:#000000;
	padding:8px 14px 8px 14px;
	text-decoration:none;
	font-size:9px;
	font-family:Verdana, Arial, Helvetica, sans-serif;
	font-weight:bold;
	text-transform:uppercase;
	border:1px solid #FFFFFF;
	background-position:bottom;
}
ul.tabs li a:hover {
background-color:#E4E3DD;
border-color:#FFFFFF;
}
ul.tabs li a.active {
	background-color:#ffffff;
	color:#282e32;
	border:1px solid #EBE9E1;
	border-bottom: 1px solid #ffffff;
	background-image:url(tab_on.jpg);
	background-repeat:repeat-x;
	background-position:top;
}
.content {
	background-color:#ffffff;
	padding:10px;
	border:1px solid #EBE9E1; 
	font-family:Arial, Helvetica, sans-serif;
	background-image:url(content_bottom.jpg);
	background-repeat:repeat-x;
	background-position:bottom;
}
#content_2, #content_3 { display:none; }
.content ul {
	margin:0px;
	padding:0px 0px 0px 0px;
}
.content ul li {
	list-style:none;
	border-bottom:1px solid #d6dde0;
	padding-top:15px;
	padding-bottom:15px;
	font-size:13px;
}
.content ul li:last-child {
border-bottom:none;
}
.content ul li a {
	text-decoration:none;
	color:#3e4346;
}
.content ul li a small {
	color:#8b959c;
	font-size:9px;
	text-transform:uppercase;
	font-family:Verdana, Arial, Helvetica, sans-serif;
	position:relative;
	left:4px;
	top:0px;
}
.content ul li a:hover {
color:#a59c83;
}
.content ul li a:hover small {
color:#baae8e;
}
</style>
</body>
</html>

Thursday, November 8, 2018

Dynamic Drag’n Drop With jQuery And PHP

Dynamic Drag’n Drop With jQuery And PHP

Database Table

CREATE TABLE IF NOT EXISTS `dragdrop` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`text` varchar(255) DEFAULT NULL,
`listorder` int(11) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=8 ;



Records

INSERT INTO `dragdrop` (`id`, `text`, `listorder`) VALUES
(1, 'Ajax', 4),
(2, 'Jquery', 2),
(3, 'PHP', 3),
(4, 'Mysql', 1),
(5, 'Javascript', 7),
(6, 'CSS', 6),
(7, 'HTML', 5);


<!DOCTYPE html>
//dynamic-dragn-drop-with-jquery-and-php.php
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Dynamic Drag Drop With jQuery ui,PHP and Mysqli</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.min.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<style>
ul {
 padding:0px;
 margin: 0px;
}
#response {
 padding:10px;
 background-color:#9F9;
 border:2px solid #396;
 margin-bottom:20px;
}
#list li {
 margin: 0 0 3px;
 padding:8px;
 background-color:#00CCCC;
 color:#fff;
 list-style: none;
 border: #CCCCCC solid 1px;
}
</style>
<script type="text/javascript">
$(document).ready(function(){  
   function slideout(){
  setTimeout(function(){
  $("#response").slideUp("slow", function () {
 });
 }, 2000);
 }
 
   $("#response").hide();
   $(function() {
  $("#list ul").sortable({ opacity: 0.8, cursor: 'move', update: function() {
    var order = $(this).sortable("serialize") + '&update=update';
    $.post("updateList.php", order, function(theResponse){
  $("#response").html(theResponse);
  $("#response").slideDown('slow');
  slideout();
    });                
   }         
    });
   });

}); 
</script>
</head>
<body>
<div id="container" style="width:300px;">
 <div id="list">
 <div id="response"> </div>
   <ul>
     <?php
$conn = new mysqli('localhost','root','','testingdb');
if ($conn->connect_error) {
    die('Error : ('. $conn->connect_errno .') '. $conn->connect_error);
}
$results = $conn->query("SELECT id, text FROM dragdrop ORDER BY listorder ASC");
 while($row = $results->fetch_assoc()) {
  $id=$row['id'];
  $text=$row['text'];
    ?>
     <li id="arrayorder_<?php echo $id ?>"><?php echo $id?> <?php echo $text; ?>
       <div class="clear"></div>
     </li>
     <?php } ?>
   </ul>
 </div>
</div>
</body>
</html>
//updatelist.php
<?php
$conn = new mysqli('localhost','root','','testingdb');
if ($conn->connect_error) {
    die('Error : ('. $conn->connect_errno .') '. $conn->connect_error);
}
$array = $_POST['arrayorder'];

if ($_POST['update'] == "update"){
 
 $count = 1;
 foreach ($array as $idval) {
  $sql = "UPDATE dragdrop SET listorder = " . $count . " WHERE id = " . $idval;
  if ($conn->query($sql) === TRUE) {
  echo "Record updated successfully";
 } else {
  echo "Error updating record: " . $conn->error;
 }
  $count ++; 
 }
 echo 'All saved! refresh the page to see the changes';
}
?>

Related Post