Page 368 - CITS - CSA - TP (Volume 1) - Hindi
P. 368

कंप्यूटर सॉफ्टवेयर एप्लीकेशन- CITS



                          <html >

                 <head> HTML form </title>
                 </head>
                 <body>

              <?php
                        // Database connection parameters
                       $servername = “localhost”;  // Change this if  MySQL server is on a different host

                       $username = “root”; // Change this to your MySQL username
                       $password = “”; // Change this to your MySQL password
                       $database = “mydb”;    // Change this to your database name

                       // Create connection
                       $conn = new mysqli($servername, $username, $password, $database);

                       // Check connection
                       if ($conn->connect_error)
                       {

                               die(“Connection failed: “ . $conn->connect_error);
                          }
                       // Check if the form is submitted

                      if ($_SERVER[“REQUEST_METHOD”] == “POST”)
                      {
                      // Get ID from the form

                      $username = $_POST[“username”];
                     // Prepare and execute the SQL statement to delete data from the table
                      $stmt = $conn->prepare(“DELETE FROM users WHERE username = ?”);

                      $stmt->bind_param(“s”, $username);
                      if ($stmt->execute())
                   {

                                 echo “Record deleted successfully”;
                      }
                   else

                   {
                                 echo “Error: “ . $conn->error;
                      }
                          // Close statement
                      $stmt->close();
                        }

                         // Close connection
                         $conn->close();


                                                           352

                                     CITS : IT & ITES - कं  ूटर सॉ वेयर ए ीके शन - अ ास 61
   363   364   365   366   367   368   369   370   371   372   373