Page 354 - Computer Software Application TP - Volume 1
P. 354

COMPUTER SOFTWARE APPLICATION - CITS











































           TASK 5: Connect to MySQL database from PHP and delete data
           i  Create an HTML form in the webpage (index.html) to collect the data from the user
              1  Open the text editor
              2  Write the following codes

                       <html >
              <head> HTML form </title>
              </head>
              <body>
                          <h2>Delete Data from MySQL Database</h2>
                          <form method=”post” action=”delete.php”>

                                 <label for=”username”>Username of Record to Delete:</label><br>
                              <input type=”text” id=”username” name=”username” required><br><br>
                                 <input type=”submit” value=”Delete”>
                          </form>

              </body>
              </html>
              3  Save the program in C:\Apache24\htdocs in a folder as index.html
           ii  Create a PHP script (delete.php) to connect to the database and handle the update process based on user
              input.
              1  Open the text editor
              2  Write the following codes
                       <html >



                                                           339

                               CITS : IT & ITES - Computer Software Application - Exercise 61
   349   350   351   352   353   354   355   356   357   358   359