Wednesday 17 October 2018

System Dashboard: MYSQLI CRUD OOP Series

This page will serve as the dashboard of the CRUD system. It calls the functionality of the class.functions.php that will be instantiated in this page.

Step 3. Create an index page for the CRUD
Filename: index.php
Code:

<?php
include 'class.functions.php';
$db = new DBfunctions();
echo $db->testing();
?>
<!DOCTYPE html>
<html>
<head>
<title>SQLI OOP::Demo System</title>
</head>
<body>
<!--Save Data Form-->
<form action='<?php echo $_SERVER['PHP_SELF'] ?>' method='post'>
<table border="1" align="center" cellpadding="0">
<th colspan="2">Userlevel Maintenance</th>
<tr>
<td>Userlevel::</td>
<td><input type="text" name="ul_name" placeholder="User level here" required></td>
</tr>
<tr>
<td>Description::</td>
<td><input type="text" name="ul_desc" placeholder="Description here" required></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" name="submit" value="Submit"></td>
</tr>
</table>
</form>
</body>
</html>

Discussion:
The first three lines of PHP at the top established the connection of the different class from class DBconn and class DBfunctions.
$db = new DBfunctions(); creates a new instance of the class DBfunctions
include 'class.functions.php'; this will make the class.functions.php become part of the actual index.php codes
echo $db->testing(); This will print the data in the function testing( ) under class.functions.php
The rest of the HTML codes, establish the web form elements that will be used in the different database operation. Web form elements should be named properly.

<form action='<?php echo $_SERVER['PHP_SELF'] ?>' method='post'>
The code tell us the submitted data will be processed by itself using method post. The post method is recommended to use when submitting data using web forms.

0 comments:

Post a Comment

If possible, leave a positive comment. No hate speech or elicit comments. Thank you.