Skip to content

Instantly share code, notes, and snippets.

<?php
include('connect.php');
//insert data into database
if(isset($_POST['save'])){
$name=$_POST['name'];
$age=$_POST['age'];
$target="images/".basename($_FILES['image']['name']);
$sql="INSERT INTO image(name,age,image)VALUES('$name','$age','$target')";
$stmt=$con->prepare($sql);
$stmt->execute();
<html>
<head>
<title>ajax example</title>
<link rel="stylesheet" href="bootstrap.css" crossorigin="anonymous">
<!-- Optional theme -->
<link rel="stylesheet" href="bootstrap-theme.css" crossorigin="anonymous">
<style>
.container{
width:70%;
height:30%;
id category subcategory_name price
1 1 Samsung 10000
2 1 Redmi 12000
3 1 Real Me 10000
4 1 Vivo 12000
5 2 Dell 30000
6 2 Lenovo Ideapad 30000
7 2 Asus 28000
<?php
//session_start();
include('connect.php');
if(isset($_POST['submit'])){
for($i=0;$i<count($_POST['slno']);$i++){
$student_name = $_POST['student_name'][$i];
$phone_no = $_POST['phone_no'][$i];
$age = $_POST['age'][$i];
$date_of_birth = $_POST['date_of_birth'][$i];
if($student_name!=='' && $phone_no!=='' && $age!=='' && $date_of_birth!==''){
<?php
//session_start();
include('connect.php');
if(isset($_POST['city_name']))
{
$city_name = $_POST['city_name'];
$stmt = $con->prepare("select * from pincodes where city_id='$city_name'");
$stmt->execute();
$pin_details = $stmt->fetch(PDO::FETCH_ASSOC);
//fetch the value into an array
<?php
//session_start();
include('connect.php');
if(isset($_POST['state_name']))
{
$state_name = $_POST['state_name'];
$stmt = $con->prepare("select * from city where state_id='$state_name'");
$stmt->execute();
$city_details = $stmt->fetchAll(PDO::FETCH_ASSOC);
$option1 = '<select class="form-control" name="city">
<?php
include('connect.php');
if(isset($_POST['search'])){
$key = $_POST['search'];
$stmt = $con->prepare("select * from users where username like '%$key%' or phone_no like '%$key%'");
$stmt->execute();
$user_details = $stmt->fetch(PDO::FETCH_ASSOC);
if($stmt->rowCount()>0)
{
$output['success'] = '<table class="table table-bordered">
<?php
include '../connect.php';
session_start();
//destroy the session
session_unset();
//redirect to login page
header("location: login.php");
?>
<?php
session_start();
include '../connect.php';
if($_SESSION['username']==''){
header("location: login.php");
}
?>
<html>
<head>
<title>ajax example</title>
<?php
include '../connect.php';
session_start();
if(isset($_POST['login'])){
$username = $_POST['username'];
$password = $_POST['password'];
//check login details
$stmt = $con->prepare("select * from users where username = '$username' and password = '$password'");
$stmt->execute();
//echo $stmt->rowCount();