Posts

ajax insert

index.php <!DOCTYPE html> <html> <head>   <title>Ajax insert</title>   <!-- Latest compiled and minified CSS --> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous"> <!-- Optional theme --> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous"> </head> <body> <div class="container">     <div class="row">           <div class="col-md-3"></div>           <div class="col-md-6">           <form >     ...

cookie login

<?php $con = mysqli_connect("localhost","root","root","cookielogin") or die(mysqli_error($con)); session_start(); if(isset($_POST['btn_login'])) {     extract($_POST);             $query=mysqli_query($con,"select * from login where  username='$username' and password='$password'" ) or die(mysqli_error($con));      $row=mysqli_fetch_assoc($query);            if($row)      {          if(!empty($_POST['re'])){          setcookie("username",$_POST['username'],time() + (48*60*60));          setcookie("password",$_POST['password'],time() + (24*60*60));          }          else          {           ...

change password

<?php           if(isset($_POST['change']))           {               include"include/connection.php";             $query='select * from enabler_register where username="'.$_SESSION['username'].'"and password="'.$_POST['pass'].'"';                $res=mysqli_query($con,$query);             if(mysqli_num_rows($res)>0)             {                 if(strlen($_POST['pass1'])>=6)                 {                     if($_POST['pass1']==$_POST['pass2'])       ...

photo upload

<html> <head>  <script src="assets/js/jquery-1.10.2.js"></script>     <!-- BOOTSTRAP SCRIPTS -->     <script src="assets/js/bootstrap.js"></script>     <!-- PAGE LEVEL SCRIPTS -->     <script src="assets/js/bootstrap-fileupload.js"></script>     <!-- METISMENU SCRIPTS -->     <script src="assets/js/jquery.metisMenu.js"></script>     <!-- CUSTOM SCRIPTS -->     <script src="assets/js/custom.js"></script>         </head> <body> <form method="post" enctype="multipart/form-data"> <input  type="file" name="photo"><br> <input type="submit" name="submit" value="SEND"> </form>     <?php         $con=mysqli_connect("localhost","root","root","img") or die(...

view record

<!DOCTYPE html> <html> <head>     <title></title> </head> <body> <?php      $dbname="demo";     $con=mysqli_connect("localhost","root","root","demo") or die(mysqli_error());    $query=mysqli_query($con,"select * from tbl1 ") or die(mysqli_error($con));    ?>    <table border="1">            <tr>                <td>Name</td>                <td>surname</td>            </tr>      <?php      while($row=mysqli_fetch_array($query))      {      extract($row);      ?>      <tr>       ...

Assignment

Image

How to insert data into Database using PHP

 1. Create Form and give name form.php, the file look like :            <form method="post" action="insert.php">              <label>Name</label>              <input type="text" name="name" />                          <label>Surname</label>              <input type="text" name="surname" />             <input type="submit" name="submit" />          </form>  2. create database connection and give name db.php and create table give name tbl1, the file look like :       <?php             $con=mysqli_connect("localhost","root","root","demo") or     die(mysqli_...

How to connect to database using PHP and MySQL

<?php $dbname="your db name"; $server="your server name e.g. localhost"; $username="your username e.g. root"; $password=" your password"; $connect = mysqli_connect($dbname,$server,$username,$password) or die(mysqli_error()); if($connect) {  echo "Database connection successfully.."; }else { echo "error while connecting  to the database"; } ?>