Posts

Showing posts from March, 2021

Multiple File Upload in PHP

Image
Multiplefile.php(frontend)   <!DOCTYPE html> <html lang="en"> <head>     <title>Document</title> </head> <body>     <form enctype="multipart/form-data" method="POST" action="marchbackend.php">          Name :<input type="text" name="name" placeholder="text"><br>     Choose File :<input type="file" name="file[]" multiple><br>         <button type="submit" name="submit">submit</button>     </form> </body> </html> Backend file <?php //multiple file code include "connection.php"; // echo "<pre>"; // print_r ($_FILES); // echo "</pre>"; if (isset($_POST["submit"]))  {     $name = $_POST['name'];     for ($i=0; $i <count($_FILES['file']['name']);$i++)      {          move_uploaded_file($_FILES['file...

Single File Upload in PHP

Image
Index.php(Frontend) <!DOCTYPE html> <html lang="en"> <head>     <title>single file upload</title> </head> <body>     <form method="POST" enctype="multipart/form-data" action="singlebackend.php">         <input type="text" name="name" placeholder="filename"><br>         <input type="file" name="file"><br>         <button type="submit">Submit</button>     </form> </body> </html> singlefile(Backend) <?php include "connection.php"; //testing sucessfully done // echo "<pre>"; // print_r ($_FILES); // echo "</pre>"; $text = $_POST['name']; $filename = $_FILES['file']['name']; $tempname = $_FILES['file']['tmp_name'];     $imgtype = $_FILES["file"]["type"]; $imgsize = $_FILES["file"...

String Function | PHP

Image
String Function <!DOCTYPE html> <html> <head>     <title></title>     <style>         h1{             text-align:center;             color:red;             background-color: black;             padding:20px;            }             body{             background-color:blanchedalmond;         }     </style> </head> <body> <h1>String Function</h1> <?php     $a=5;     $b=85;     $c=9;     $d=($a*$b)%$c;     echo "1. Arithmetic Oparetor value int:- ".($d)."<hr>"; //concatenate        $name="shuvadeep";     $age=24;     $address="Bhubaneswar";   ...

Sign Up / Login (CODE) backend PHP with $_SESSION

Image
  Sign Up (Frontend Code) <!DOCTYPE html> <html lang="en"> <head>     <meta charset="UTF-8">     <meta http-equiv="X-UA-Compatible" content="IE=edge">     <meta name="viewport" content="width=device-width, initial-scale=1.0">     <title>sign up</title> </head> <body> <h1>Sign Up</h1> <form method="POST" action="signup_backend.php">     <label>User Name :</label>     <input type="text" name="client_username" placeholder="Enter Username"><br>     <label>Email :</label>     <input type="email" name="client_email" placeholder="Enter Email ID"><br>     <label>Password :</label>     <input type="password" name="client_password" placeholder="Enter Password"><br>     <label...

Excel File Upload to Database Format (csv) PHP

Image
index.php (frontend-file) <!DOCTYPE html> <html lang="en"> <head>     <meta charset="UTF-8">     <meta http-equiv="X-UA-Compatible" content="IE=edge">     <meta name="viewport" content="width=device-width, initial-scale=1.0">     <title>Document</title> </head> <body>     <form method="POST" action="process.php" enctype="multipart/form-data">         Choose File :<input type="file" name="userfile" required><br><br>         <input type="submit" name="usersave" value="submit">     </form>     </body> </html> backend file <?php include "conn.php"; //testing sucessfully done //echo "<pre>"; //print_r($_FILES); //echo "</pre>"; if (isset($_POST['usersave']))  {        $upload_file = $_FILES[...

$_session in php/ login form/ signup form and with backend.php (dashboard.php/ logout.php) CODE

Image
  DATABASE   Connection.php <?php $db_server = "localhost"; $db_username = "root"; $db_password = ""; $db_name = "projectone"; $conn = mysqli_connect($db_server, $db_username, $db_password, $db_name); // if (!$conn) // { //     die("connection failed:".mysqli_connect_error()); // } // echo "connected Successfully";   ?> Login.php <!DOCTYPE html> <html lang="en"> <head>     <meta charset="UTF-8">     <meta http-equiv="X-UA-Compatible" content="IE=edge">     <meta name="viewport" content="width=device-width, initial-scale=1.0">     <title>login</title> </head> <body>     <h1>Log In</h1> <form method="POST" action="loginbackend.php">     <label>Email :</label>     <input type="text" name="user_email" placeholder="Enter Email...

Prime Number In PHP

  //Prime Number: 5 to 250 task... $prime = 250;     echo "<h1 style=color:red;text-align:center;background-color:black;font-size:50px;>Prime Number: 5 to 250...</h1>"; //ye loop 5 se lekar 250 tak chalayega. for ($i=5; $i <= $prime; $i++) {      $isprime = true; //ye loop i divided by 2 aur if statement reminder nikalega 0 hua to false aur 1 hua to true. for ($j=2; $j <= ($i/2); $j++) {      if ($i % $j == 0) {  //aur if statement reminder nikalega 0 hua to false aur 1 hua to true.         $isprime = false;     } }     if ($isprime == true) {         echo "This is Prime Number: ".$i.'<br>';     } } ----------------------------------------------------------------------------------------------------------------------------- Task while loop 5 to 250. $a = 5; while ($a <= 250)  {      $c = $a-1;      $d = $a+1;...

Associative Array

Associative Array   <?php //associative array:-      $a = array (         "mac"=> 75000,         "dell"=> 50000,         "acer"=> 47000     );     //when we change the value then we type $variable then [bracket] = change value.      $a["dell"] = 57000;     //print_r is for testing array value and key.     echo "<pre>";     print_r ($a)."<br>";     echo "</pre>";     //This one you call the key. The output comes only value not keyword (mind this).     echo $a["acer"]."<br>";     echo $a["mac"]."<br>";     echo $a["dell"];     //Associative array bahat jyada use hota hai database ke sath ?> Output Array ( [mac] => 75000 [dell] => 57000 [acer] => 47000 ) 47000 75000 57000

Multidimensional arrays in PHP (TASK)

 Multidimensional arrays question $x = [     'name'=> 'pheonix',     'email'=> 'pheonix10@gmail.com',     'mob'=> '998855172',     'sub'=> ['math,science,english'],     'number'=> ['a'=>1, 'b'=>2,'c'=>3] ]; code foreach ($x as $k => $value)  {          if($k == 'sub')     {         for ($i=0; $i < count($value); $i++)          {              echo $k.": ".$value[$i]."<br>";         }     }     elseif ($k == 'number')      {         echo $k.":";         foreach ($value as $k1 => $value1)          {             echo $value1;          }     }else {         echo $k.": ".$value; ...

C.R.U.D Oparetion in (PHP Code)

C.R.U.D Oparetion   index.php <?php include "conn.php"; if (isset($_POST["usersubmit"]))  {     $vrname = $_POST["username"];     $vremployee = $_POST["useremployee"];     $vrsalary = $_POST["usersalary"];     $vrgender = $_POST["gender"];     //testing sucessfully complete     // echo $vrname;     // echo $vremployee;     // echo $vrsalary;     // echo $vrgender;     // exit();     $inserting = "INSERT INTO dbemployeelist(dbname, dbemployee, dbsalary, dbgender) VALUES('$vrname', '$vremployee', '$vrsalary', '$vrgender')";     $connecting = mysqli_query($conn,$inserting); } ?> <!DOCTYPE html> <html lang="en"> <head>     <title>Document</title>     <style>         form{             text-align:center;             padding:2...