Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
jancordeiro authored Apr 25, 2023
1 parent 81b92b0 commit 1c4c6f0
Show file tree
Hide file tree
Showing 17 changed files with 921 additions and 0 deletions.
22 changes: 22 additions & 0 deletions config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

// PHP file to connect to the database
// Sample created by Jan Cordeiro

$servername = "localhost";
$username = "u403007536_root";
$password = "J8k4n2v4";
$database = "u403007536_sampleform";

$conexao = new mysqli($servername,$username,$password,$database)

// if ($conexao->connect_errno)
// {
// echo "Failed to connect to the database";
// }
// else
// {
// echo "The connection was successful";
// }

?>
123 changes: 123 additions & 0 deletions dashboard.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
<?php
session_start();
// print_r($_SESSION);
include_once('config.php');
if((!isset($_SESSION['email']) == true) and (!isset($_SESSION['password']) == true))
{
unset($_SESSION['email']);
unset($_SESSION['password']);
header('Location: login.php');
}
$logged = $_SESSION['email'];
if(!empty($_GET['search']))
{
$data = $_GET['search'];
$sql = "SELECT * FROM user WHERE id LIKE '%$data%' or name LIKE '%$data%' or email LIKE '%$data%' ORDER BY id DESC";
}
else
{
$sql = "SELECT * FROM user ORDER BY id DESC";
}
$result = $conexao->query($sql);
?>
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE-edge">
<meta name="viewport" content="width=devide-width, initial-scale=1.0">
<!-- <link rel="stylesheet" type="text/css" href="dashboard.css"> -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
<title>Sample Dashboard</title>
<style>
body {
background-image: linear-gradient(to right, rgb(20, 147, 220), rgb(17, 54, 71));
color: white;
text-align: center;
}

.table-bg {
background: rgba(0,0,0,0.3);
border-radius: 15px 15px 0 0;
}

.box-search {
display: flex;
justify-content: center;
gap: .1%;
}
</style>
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-dark bg-primary">
<div class="container-fluid">
<a class="navbar-brand" href="#">DASHBOARD LESSION</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
</div>
<div class="d-flex">
<a href="logout.php" class="btn btn-danger me-5">LOGOUT</a>
</nav>
<br />
<?php
echo "<h1>Welcome, $logged to the Dashboard!</h1>"
?>
<br />
<div class="box-search">
<input type="search" class="form-control w-25" placeholder="Search" id="searchbox">
<button onclick ="searchData()" class="btn btn-primary">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-search" viewBox="0 0 16 16">
<path d="M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001c.03.04.062.078.098.115l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85a1.007 1.007 0 0 0-.115-.1zM12 6.5a5.5 5.5 0 1 1-11 0 5.5 5.5 0 0 1 11 0z"/>
</svg>
</button>
</div>
<div class="m-5">
<table class="table table-bg">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">Name</th>
<th scope="col">Email</th>
<th scope="col">Phone</th>
<th scope="col">Gender</th>
<th scope="col">Date of Birth</th>
<th scope="col">City</th>
<th scope="col">State</th>
<th scope="col">Address</th>
<th scope="col">Action</th>
</tr>
</thead>
<tbody>
<?php
while($user_data = mysqli_fetch_assoc($result))
{
echo "<tr>";
echo "<td>".$user_data['id']."</td>";
echo "<td>".$user_data['name']."</td>";
echo "<td>".$user_data['email']."</td>";
echo "<td>".$user_data['phone']."</td>";
echo "<td>".$user_data['gender']."</td>";
echo "<td>".$user_data['date_of_birth']."</td>";
echo "<td>".$user_data['city']."</td>";
echo "<td>".$user_data['state']."</td>";
echo "<td>".$user_data['address']."</td>";
echo "<td>
<a class='btn btn-sm btn-primary' href='edit.php?id=$user_data[id]'>
<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='currentColor' class='bi bi-pencil' viewBox='0 0 16 16'>
<path d='M12.146.146a.5.5 0 0 1 .708 0l3 3a.5.5 0 0 1 0 .708l-10 10a.5.5 0 0 1-.168.11l-5 2a.5.5 0 0 1-.65-.65l2-5a.5.5 0 0 1 .11-.168l10-10zM11.207 2.5 13.5 4.793 14.793 3.5 12.5 1.207 11.207 2.5zm1.586 3L10.5 3.207 4 9.707V10h.5a.5.5 0 0 1 .5.5v.5h.5a.5.5 0 0 1 .5.5v.5h.293l6.5-6.5zm-9.761 5.175-.106.106-1.528 3.821 3.821-1.528.106-.106A.5.5 0 0 1 5 12.5V12h-.5a.5.5 0 0 1-.5-.5V11h-.5a.5.5 0 0 1-.468-.325z'/>
</svg></a>
<a class='btn btn-sm btn-danger' href='delete.php?id=$user_data[id]'>
<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='currentColor' class='bi bi-trash-fill' viewBox='0 0 16 16'>
<path d='M2.5 1a1 1 0 0 0-1 1v1a1 1 0 0 0 1 1H3v9a2 2 0 0 0 2 2h6a2 2 0 0 0 2-2V4h.5a1 1 0 0 0 1-1V2a1 1 0 0 0-1-1H10a1 1 0 0 0-1-1H7a1 1 0 0 0-1 1H2.5zm3 4a.5.5 0 0 1 .5.5v7a.5.5 0 0 1-1 0v-7a.5.5 0 0 1 .5-.5zM8 5a.5.5 0 0 1 .5.5v7a.5.5 0 0 1-1 0v-7A.5.5 0 0 1 8 5zm3 .5v7a.5.5 0 0 1-1 0v-7a.5.5 0 0 1 1 0z'/>
</svg></a>
</td>";
echo "</tr>";
}
?>
</tbody>
</table>
</div>
</body>
<script src="search.js"></script>
</html>
22 changes: 22 additions & 0 deletions delete.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

if(!empty($_GET['id']))
{

include_once('config.php');

$id = $_GET['id'];

$sqlSelect = "SELECT * FROM user WHERE id=$id";

$result = $conexao->query($sqlSelect);

if($result->num_rows > 0)
{
$sqldelete = "DELETE FROM user WHERE id=$id";
$resultdelete = $conexao->query($sqldelete);
}

}
header('Location: dashboard.php');
?>
113 changes: 113 additions & 0 deletions edit.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
<?php

if(!empty($_GET['id']))
{

include_once('config.php');

$id = $_GET['id'];

$sqlSelect = "SELECT * FROM user WHERE id=$id";

$result = $conexao->query($sqlSelect);

if($result->num_rows > 0)
{
while($user_data = mysqli_fetch_assoc($result))
{
$name = $user_data['name'];
$email = $user_data['email'];
$password = $user_data['password'];
$phone = $user_data['phone'];
$gender = $user_data['gender'];
$date_of_birth = $user_data['date_of_birth'];
$city = $user_data['city'];
$state = $user_data['state'];
$address = $user_data['address'];
}


}
else
{
header('Location: dashboard.php');
}

}
else
{
header('Location: dashboard.php');
}

?>

<!DOCTYPE HTML>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE-edge">
<meta name="viewport" content="width=devide-width, initial-scale=1.0">
<link rel ="stylesheet" type="text/css" href="form.css">
<title>Form</title>
</head>
<body>
<br />
<a href="dashboard.php">Back to Dashboard</a>
<div class="box col-3 col-s-11">
<form action="saveedit.php" method="POST">
<fieldset>
<legend><b>Edit User Data</b></legend>
<br />
<div class="inputbox">
<input type="text" name="name" id="name" class="inputuser" value="<?php echo $name ?>" required>
<label for="name" class="inputlabel">Full Name</label>
</div><br />

<div class="inputbox">
<input type="text" name="email" id="email" class="inputuser" value="<?php echo $email ?>" required>
<label for="email" class="inputlabel">Email</label>
</div><br />

<div class="inputbox">
<input type="text" name="password" id="password" class="inputuser" value="<?php echo $password ?>" required>
<label for="password" class="inputlabel">Password</label>
</div><br />

<div class="inputbox">
<input type="tel" name="phone" id="phone" class="inputuser" value="<?php echo $phone ?>" required>
<label for="phone" class="inputlabel">Phone Number</label>
</div><br />

<p>Sexo:</p>
<input type="radio" name="gender" id="female" value="female" <?php echo ($gender == 'female') ? 'checked' : '' ?> required>
<label for="female">Female</label><br />
<input type="radio" name="gender" id="male" value="male" <?php echo ($gender == 'male') ? 'checked' : '' ?> required>
<label for="male">Male</label><br />
<input type="radio" name="gender" id="other" value="other" <?php echo ($gender == 'other') ? 'checked' : '' ?> required>
<label for="other">Other</label><br /><br />

<label for="date"><b>Date of Birth:</b></label>
<input type="date" name="date_of_birth" id="date_of_birth" value="<?php echo $date_of_birth ?>" required>
<br /><br />

<div class="inputbox">
<input type="text" name="city" id="city" class="inputuser" value="<?php echo $city ?>" required>
<label for="city" class="inputlabel">City</label>
</div><br />
<div class="inputbox">
<input type="text" name="state" id="state" class="inputuser" value="<?php echo $state ?>" required>
<label for="state" class="inputlabel">State</label>
</div><br />
<div class="inputbox">
<input type="text" name="address" id="address" class="inputuser" value="<?php echo $address ?>" required>
<label for="address" class="inputlabel">Address</label>
</div><br />
<input type="hidden" name="id" value="<?php echo $id ?>">
<input type="submit" name="update" id="update" value="Submit">
</fieldset>

</form>
</div>

</body>
</html>
65 changes: 65 additions & 0 deletions form-css.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
body {
font-family: Arial, Helvetica, sans-serif;
background-image: linear-gradient(to right, rgb(20, 147, 220), rgb(17, 54, 71));
}

.box {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background-color: rgba(0, 0, 0, 0.6);
padding: 15px;
border-radius: 15px;
widht: 20%;
color: white;
}

fieldset {
border: 3px solid dodgerblue;
}

legend {
border: 1px solid dodgerblue;
padding: 10px;
text-align: center;
background-color: dodgerblue;
border-radius: 8px;
}

.inputbox {
position: relative;
}

.inputuser {
background: none;
border: none;
border-bottom: 1px solid white;
outline: none;
color: white;
font-size: 15px;
width: 100%;
letter-spacing: 2px;
}

.inputlabel {
position: absolute;
top: 0px;
left: 0px;
pointer-events: none;
transition: .5s;
}

.inputuser:focus ~ .inputlabel,
.inputuser:valid ~ .inputlabel {
top: -20px;
font-size: 12px;
color: dodgerblue;
}

#date_of_birth {
border: none;
padding: 8px;
border-radius: 10px;
outline: none;
}
Loading

0 comments on commit 1c4c6f0

Please sign in to comment.