Professional Documents
Culture Documents
3A Pareño FINALS
3A Pareño FINALS
FINALS
Name: Jayson Pareño
Course: BSIT
Section: 3A
Module 9
Exercise 1
No. 4
Source Code:
<?php
$servername = "localhost:3308";
$username = "root";
$password = "";
$database = "";
if (mysqli_connect_error())
{
die("Connection failed: " . mysqli_connect_error());
} echo "Connection successfully established!<br>";
//$conn->closes();
?>
Output:
No. 6
Source Code:
<?php
$servername = "localhost:3308";
$username = "root";
$password = "";
$database = "";
if (mysqli_connect_error())
{
die("Connection failed: " . mysqli_connect_error());
} echo "Connection successfully established!<br>";
//Create database
if (mysqli_query($conn, $sql)) {
echo "Database was successfully created";
}
else {
echo "ERROR: Could not able to excute $sql. " . mysqli_error($conn);
}
Output:
No. 7
No. 8
No. 9
No. 11
Source Code:
if (mysqli_query($conn, $sql)) {
echo "The table was successfully created";
}
else {
echo "ERROR: Could not able to execute $sql." . mysqli_error($conn);
}
Output:
No. 12
No. 14 , 15, 16
Source Code:
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<?php
include 'conn[Pareno].php';
if(isset($_POST['btn_save']))
{
$firstname=$_POST['firstname'];
$lastname=$_POST['lastname'];
$email=$_POST['email'];
$password=$_POST['password'];
$birthday=$_POST['birthday'];
$gender=$_POST['gender'];
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<?php
include 'conn[Pareno].php';
?>
<table width="100%" border="1" style="border-collapse:collapse;">
<thead>
<th>User ID</th>
<th>Firstname</th>
<th>Lastname</th>
<th>Email</th>
<th>Password</th>
<th>Birthday</th>
<th>Gender</th>
<th>Delete</th>
</thead>
<tbody>
<?php
$count=1;
$sel_query= "SELECT * FROM tbl_user;";
$result=mysqli_query($conn,$sel_query);
while($row=mysqli_fetch_assoc($result)) {?> -Confidential-
<tr>
<td align="center"><?php echo $row['user_id']; ?></td>
<td align="center"><?php echo $row['firstname']; ?></td>
<td align="center"><?php echo $row['lastname']; ?></td>
<td align="center"><?php echo $row['email']; ?></td>
<td align="center"><?php echo $row['password']; ?></td>
<td align="center"><?php echo $row['birthday']; ?></td>
<td align="center"><?php echo $row['gender']; ?></td>
</tr>
<?php $count++; } ?>
</tbody>
</table>
</body>
</html>
No. 20
Module 10
Exercise 2
No. 3
Source Code:
<!DOCTYPE html>
<html>
<head>
<title></title>
<style type="text/css">
table,th,td {border:1px solid black;}
</style>
</head>
<body>
<?php
include 'conn[Pareno].php';
?>
<table width="100%" border="1" style="border-collapse:collapse;">
<thead>
<th>User ID</th>
<th>Firstname</th>
<th>Lastname</th>
<th>Email</th>
<th>Password</th>
<th>Birthday</th>
<th>Gender</th>
<th>Update</th>
</thead>
<tbody>
<?php
$count=1;
$sel_query= "SELECT * FROM tbl_user;";
$result=mysqli_query($conn,$sel_query);
while($row=mysqli_fetch_assoc($result)) {?> -Confidential-
<tr>
<td align="center"><?php echo $row['user_id']; ?></td>
<td align="center"><?php echo $row['firstname']; ?></td>
<td align="center"><?php echo $row['lastname']; ?></td>
<td align="center"><?php echo $row['email']; ?></td>
<td align="center"><?php echo $row['password']; ?></td>
<td align="center"><?php echo $row['birthday']; ?></td>
<td align="center"><?php echo $row['gender']; ?></td>
<td align="center">
<a href="update[Pareno].php?user_id=<?php echo $row["user_id"];?>">Update</a>
</td>
</tr>
<?php $count++; } ?>
</tbody>
</table>
</body>
</html>
Exercise 2
No. 5
Source Code:
<?php
include 'conn[Pareno].php';
$user_id=$_REQUEST['user_id'];
?>
<!DOCTYPE HTML>
<html>
<head>
<title></title>
</head>
<body>
<?php
if(isset($_POST['btn_update'])){
$user_id=$_REQUEST['user_id'];
$firstname=$_POST['firstname'];
$lastname=$_POST['lastname'];
$email=$_POST['email'];
$password=$_POST['password'];
$birthday=$_POST['birthday'];
$gender=$_POST['gender'];
<div id="wrap">
<div class="cont_ord">
<legend>Form</legend>
<div class='field_container'>
<form action="" method="post">
<div class='cont_details'>
<fieldset>
<legend>Contact Details</legend>
<label for="Firstname">User ID</label>
<br>
<input type="text" name="user_id" value="<?php echo $row['user_id'];?>"/>
<br>
<label for="Firstname">First Name</label>
<br>
<input type="text" name="firstname" value="<?php echo $row['firstname'];?>"/>
<br>
<label for="Lastname">Last Name</label>
<br>
<input type="text" name="lastname" value="<?php echo $row['lastname'];?>"/>
<br>
<label for="Email">Email</label>
<br>
<input type="text" name="email" value="<?php echo $row['email'];?>"/>
<br>
<label for="Password">Password</label>
<br>
<input type="password" name="password" value="<?php echo $row['password'];?>"/>
<br>
<label for="Birthday">Birthday</label>
<br>
<input type="text" name="birthday" value="<?php echo $row['birthday'];?>"/>
<br>
<label for="Gender">Gender</label>
<br>
<input type="text" name="gender" value="<?php echo $row['gender'];?>"/>
<br>
</fieldset>
</div>
<br>
<input type="submit" name="btn_update" value="update"/>
<br>
</form>
</div>
</div>
</div>
</body>
</html>
No. 7
No. 8
No. 9
No. 12
No. 13
No. 14