Posts

Showing posts from July, 2022

PHP PROGRAMS

 DATAFETCH.HTML <!DOCTYPE html> <html> <head>     <meta charset="utf-8">     <meta name="viewport" content="width=device-width, initial-scale=1">     <title> </title> </head> <body> <form method="post"action="nameShort.php">     <label>Enter name: </label>     <input type="text" name="str1" id="str1">     <input type="submit" name="submit" id="Submit"> </form> </body> </html>   nameShort.php <?php $str = $_REQUEST['str1']; // echo strlen($str); $fstr = array(); $ws = true; for($i=0; $i< strlen($str); $i++){     if($str[$i] == ' ')     {            $ws=true;     }     else if($str[$i]!= ' ' && $ws==true)     {                array_push($fstr,$str[$i]);         $ws = false;     } } for($i=0; $i<sizeof($fstr) ; $i++){     echo $fstr[$i]; }

JAVASCRIPT

BIGTOSMALL.PHP // program to find the largest among three numbers // take input from the user // const num1 = parseFloat(prompt("Enter first number: ")); // const num2 = parseFloat(prompt("Enter second number: ")); // const num3 = parseFloat(prompt("Enter third number: ")); // const largest = Math.max(num1, num2, num3); // // display the result // console.log("The largest number is " + largest); // program to find the largest among three numbers // take input from the user document.write("<br>The largest number from -20 20 0 <br>"); const num1 = 20; const num2 = -20; const num3 = 0; let largest,smallest; // check the condition if(num1 >= num2 && num1 >= num3) {     largest = num1; } else if (num2 >= num1 && num2 >= num3) {     largest = num2; } else {     largest = num3; } // check the condition if(num1 < num2 && num1 < num3) {     smallest = num1; } else if (num2 < num1 &&

VALIDATION IN PHP OR JS

 MOBILE VALIDATAION <!DOCTYPE html> <html> <head>     <meta charset="utf-8">     <meta name="viewport" content="width=device-width, initial-scale=1">     <title> </title>     <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script> </head> <body>     <div id="container">         <label>Enter Mobile No: </label>         <input type="text" id="phone" placeholder="Enter 10 digit mobile no.."><br>         <small style="visibility: hidden;">Error MSg</small>         <br><input type="submit" id="Submit" value="Click to Validate">     </div> <script type="text/javascript">          $("document").ready(function(){         $("#Submit").click(function(){             const phoneVal = $(&q

SESSION AND COOKIE IN PHP

 first_session.php <?php session_start(); $_SESSION["name"] = "SK SAIF UDDIN"; $_SESSION["degree"] = "BCA"; echo $_SESSION["name"]."<br>"; echo $_SESSION["degree"]."<br>"; // session_unset(); // session_destroy(); echo $_SESSION["name"]."<br>"; ?>  second_session.php <?php session_start(); echo "my name is ".$_SESSION['name']; echo "<br>My degree is ".$_SESSION['degree']; ?>  third_session.php <?php session_start(); echo "My degree is ".$_SESSION['degree']; ?>    TASK 1==== index.php <!DOCTYPE html> <html> <head>     <meta charset="utf-8">     <meta name="viewport" content="width=device-width, initial-scale=1">     <title> </title> </head> <body> <div class="container">     <form action="

PHP TASKS

 array combine and array merge => <!-- TAKE 4 index array, merging th e array using array_combine function.  --> <?php $a = array("red","green","blue","orange"); $b = array("yellow","brown","silver","purple"); $c = array("gray","white","black","golden"); $d = array("violet","skyblue","pink","silver"); $e = array_combine($b, $a); $e2 = array_combine($c, $d); print_r($e); echo "<br>=====<br>"; print_r($e2); echo "<br>=====<br>"; print_r (array_merge($e, $e2)); // array_combine // $a = array("red","green","blue","orange"); // $b = array("yellow","brown","silver","purple"); // $c = array("gray","white","black","golden"); // $d = array("violet","

OOPs

 abstract.php   <?php abstract class A{     abstract function abc();     // function abc();     // cotain 1 abstract meethod : must implement this method.     // either class -> abstract class     // or declare the function     // function abc();     // non-abstract method: must contain body.     function xyz(){         echo "this is xyz";     } } class B extends A{     function mno(){         echo "This is child calss: mno()";     }     function abc(){         echo "This is child calss: mno()";     } } $obj= new B(); $obj->abc(); echo "<br>"; $obj->mno(); echo "<br>"; $obj->xyz(); ?>    Access specifier.php <?php class Student{     public $a=10;     private $b=20;     protected $c=30;     function xyz(){         echo $this->a;         echo "<br>";         echo $this->b;         echo "<br>";         echo $this->c;         echo "<br>";     } } class

Multi image

 Login.php <!DOCTYPE html> <html> <head>     <title>abc</title> </head> <body> <form method="post" action="loginaction.php">     enter email:<input type="email" name="email"><br>     enter password:<input type="password" name="password"><br>     <input type="submit" name="submit" value="submit"><br>     <a href="forminsert.php">New registration</a> </form> </body> </html> connection.php <?php $servername="localhost"; $username="root"; $password=""; $db="mwf9to12"; $conn=mysqli_connect($servername,$username,$password,$db); //print_r($conn); ?> loginaction.php <?php session_start(); include("connection.php"); $email=$_REQUEST["email"]; $pass=md5($_REQUEST["password"]); //echo $email,$pass; $sql="

XMLHttpRequest

Display.php   <!DOCTYPE html> <html> <head>     <meta charset="utf-8">     <meta name="viewport" content="width=device-width, initial-scale=1">     <title></title> </head> <body>     Enter name: <input type="text" id="name">      <button id="b1" onclick="fun()">Submit</button>     <p id="p1"></p> <script type="text/javascript">     function fun(){ var str = document.getElementById("name").value; var req = new XMLHttpRequest(); req.open("post","server.php?name="+str); req.send(); req.onreadystatechange= function(){     if(req.readyState == 4 && req.status ==200){         document.getElementById("p1").innerHTML = req.responseText;     }      }     } </script> </body> </html>    Jquery form = <!DOCTYPE html> <html> <head>     <

RESTAURANT USING PDO

 CONNECTION PAGE <?php $servername = "localhost"; $username = "root"; $password = ""; $db="mwf9to12"; try{     $conn = new PDO("mysql:host={$servername};dbname={$db}",$username,$password); }catch(PDOException $e){     echo $e->getMessage(); }//catch ?> LOGIN PAGE: <!DOCTYPE html> <html> <head>     <meta charset="utf-8">     <meta name="viewport" content="width=device-width, initial-scale=1">     <title>LOGIN ADMIN</title>     <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.0-beta1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-0evHe/X+R7YkIZDRvuzKMRqM+OrBnVFBL6DOitfPri4tjfHxaWutUpFmBp4vmVor" crossorigin="anonymous">   </head> <body> <h2 class="mx-auto w-50 mt-3 text-center">Happy Restautant</h2> <hr class="mx-auto w-50 mt-3"> <form metho