CS521 Assignment-2 Solution
CS521 Assignment-2 Solution
1. Install MySQL
- Download and install the latest version of MySQL from [MySQL’s official
website](https://dev.mysql.com/downloads/).
2. Create a Table
Run the following SQL commands in your MySQL database to create the
required table:
```sql
USE LoanDatabase;
Applicant_Name VARCHAR(50),
Monthly_Income INT,
Employment_Type VARCHAR(50),
CNIC BIGINT,
Cell BIGINT,
Amount INT
);
```
3. PHP Form for Data Input:
```php
<?php
$servername = “localhost”;
$dbname = “LoanDatabase”;
// Create connection
// Check connection
If ($conn->connect_error) {
$action = $_POST[‘action’];
$applicant_name = $_POST[‘applicant_name’];
$monthly_income = $_POST[‘monthly_income’];
$employment_type = $_POST[‘employment_type’];
$cnic = $_POST[‘cnic’];
$cell = $_POST[‘cell’];
$amount = $_POST[‘amount’];
SET Monthly_Income=’$monthly_income’,
Employment_Type=’$employment_type’, Cell=’$cell’, Amount=’$amount’
WHERE CNIC=’$cnic’”;
$result = $conn->query($sql);
If ($result->num_rows > 0) {
} else {
}
}
} else {
$conn->close();
?>
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<label>Applicant Name:</label>
<label>Monthly Income:</label>
<label>Employment Type:</label>
<label>Cell#:</label>
<label>Loan Amount:</label>
</form>
</body>
</html>
```
4. Explanation of Buttons