-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit ad26f44
Showing
8 changed files
with
340 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
#defind database info | ||
$host = "localhost"; | ||
$username = "boy"; | ||
$password = "12345"; | ||
$database = "database"; | ||
|
||
#connecting to mysqli | ||
$con = new mysqli($host, $username, $password, $database); | ||
|
||
if ($con->connect_error) { | ||
die("Connection failed: " . $con->connect_error); | ||
} | ||
|
||
|
||
|
||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
include_once("database.php"); | ||
|
||
$id = $_GET['id']; | ||
|
||
$sql = "UPDATE userdata SET `action`='0' WHERE id=$id"; | ||
|
||
if ($con->query($sql) === TRUE) { | ||
//echo "Record updated successfully"; | ||
header("Location: index.php"); | ||
} else { | ||
echo "Error updating record: " . $con->error; | ||
} | ||
|
||
$con->close(); | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
<?php include("database.php"); | ||
|
||
$sql = "SELECT * FROM userdata"; | ||
$result = $con->query($sql); | ||
?> | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<title>Bootstrap Example</title> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"> | ||
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/jquery.slim.min.js"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script> | ||
</head> | ||
<body> | ||
<nav class="navbar navbar-expand-sm bg-dark navbar-dark"> | ||
<ul class="navbar-nav"> | ||
<li class="nav-item active"> | ||
<a class="nav-link disabled" href="#">List</a> | ||
</li> | ||
<li class="nav-item"> | ||
<a class="nav-link" href="insert.html">Add New</a> | ||
</li> | ||
</ul> | ||
</nav> | ||
<div class="container"> | ||
<div class="row"> | ||
<div class="col-sm-12"> | ||
<table class="table table-hover"> | ||
<thead class="thead-light"> | ||
<tr> | ||
<th>Firstname</th> | ||
<th>Lastname</th> | ||
<th>Phone Number</th> | ||
<th></th> | ||
</tr> | ||
</thead> | ||
<?php | ||
if ($result->num_rows > 0) { | ||
// output data of each row | ||
foreach ($result as $row) { | ||
?> | ||
<tr> | ||
<td><?= $row["fname"] ?></td> | ||
<td><?= $row["lname"] ?></td> | ||
<td><?= $row["pnum"] ?></td> | ||
<td> | ||
<div class="btn-group btn-group-lg"> | ||
<a class="btn btn-danger" href="detele.php?id=<?= $row["id"] ?>">Delete</a> | ||
<a class="btn btn-primary" href="update.php?id=<?= $row["id"] ?>">Update</a> | ||
<a class="btn btn-warning" href="view.php?id=<?= $row["id"] ?>">View</a> | ||
</div> | ||
</td> | ||
</tr> | ||
<?php | ||
} | ||
} | ||
?> | ||
<tbody> | ||
</tbody> | ||
</table> | ||
</div> | ||
</div> | ||
<div class="row"> | ||
<div class="col-sm-6"> | ||
<h4>Next feature : Import Databases.</h4> | ||
|
||
</div> | ||
</div> | ||
</div> | ||
|
||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<title>Add New</title> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"> | ||
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/jquery.slim.min.js"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script> | ||
</head> | ||
<body> | ||
<nav class="navbar navbar-expand-sm bg-dark navbar-dark"> | ||
<ul class="navbar-nav"> | ||
<li class="nav-item"> | ||
<a class="nav-link" href="index.php">List</a> | ||
</li> | ||
<li class="nav-item active"> | ||
<a class="nav-link disabled" href="#">Add New</a> | ||
</li> | ||
</ul> | ||
</nav> | ||
<div class="container"> | ||
<div class="row"> | ||
<div class="col-sm-6"> | ||
<form method="post" action="insert.php"> | ||
<div class="form-group"> | ||
<label for="usr">First Name:</label> | ||
<input type="text" class="form-control" id="fname" name="fname"> | ||
</div> | ||
<div class="form-group"> | ||
<label for="usr">Last Name:</label> | ||
<input type="text" class="form-control" id="lname" name="lname"> | ||
</div> | ||
<div class="form-group"> | ||
<label for="usr">Phone Number:</label> | ||
<input type="text" class="form-control" id="pnum" name="pnum"> | ||
</div> | ||
<div class="btn-group"> | ||
<button type="submit" class="btn btn-primary" name="insert">Insert</button> | ||
</div> | ||
</form> | ||
</div> | ||
<div class="col-sm-6"> | ||
|
||
|
||
</div> | ||
|
||
</div> | ||
</div> | ||
|
||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
include_once("database.php"); | ||
|
||
function getData(){ | ||
$data = array(); | ||
$data[1] = $_POST["fname"]; | ||
$data[2] = $_POST["lname"]; | ||
$data[3] = $_POST["pnum"]; | ||
return $data; | ||
} | ||
|
||
if(!isset($_POST["insert"])){ | ||
die("POST is not insert."); | ||
}else{ | ||
$info = getData(); | ||
} | ||
|
||
$sql = "INSERT INTO userdata | ||
(fname, lname, pnum, `action`) | ||
VALUES | ||
('$info[1]', '$info[2]', '$info[3]', '1')"; | ||
|
||
if ($con->query($sql) === TRUE) { | ||
echo "New record created successfully.</br>"; | ||
echo "If you wanna back to list <a href=\"index.php\">Click here.</a>></br>"; | ||
echo "If you wanna make another contact <a href=\"insert.html\">Click here.</a>>"; | ||
} else { | ||
echo "Error: " . $sql . "<br>" . $conn->error; | ||
} | ||
|
||
$con->close(); | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<?php include_once("database.php"); | ||
|
||
$id = $_GET['id']; | ||
|
||
$sql = "SELECT * FROM userdata WHERE id=$id"; | ||
$result = $con->query($sql); | ||
foreach($result as $row){ | ||
$fname = $row['fname']; | ||
$lname = $row['lname']; | ||
$pnum = $row['pnum']; | ||
$con->close(); | ||
} | ||
?> | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<title>Updating <?php echo $fname." ".$lname;?></title> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"> | ||
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/jquery.slim.min.js"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script> | ||
</head> | ||
<body> | ||
<nav class="navbar navbar-expand-sm bg-dark navbar-dark"> | ||
<ul class="navbar-nav"> | ||
<li class="nav-item"> | ||
<a class="nav-link" href="index.php">List</a> | ||
</li> | ||
<li class="nav-item"> | ||
<a class="nav-link" href="insert.html">Add New</a> | ||
</li> | ||
</ul> | ||
</nav> | ||
<div class="container"> | ||
<div class="row"> | ||
<div class="col-sm-6"> | ||
<form method="post" action="update2.php"> | ||
<input type="hidden" name="id" value="<?php echo $id;?>"> | ||
<div class="form-group"> | ||
<label for="usr">First Name:</label> | ||
<input type="text" class="form-control" id="fname" name="fname" value="<?php echo $fname;?>"> | ||
</div> | ||
<div class="form-group"> | ||
<label for="usr">Last Name:</label> | ||
<input type="text" class="form-control" id="lname" name="lname" value="<?php echo $lname;?>"> | ||
</div> | ||
<div class="form-group"> | ||
<label for="usr">Phone Number:</label> | ||
<input type="text" class="form-control" id="pnum" name="pnum" value="<?php echo $pnum;?>"> | ||
</div> | ||
<div class="btn-group"> | ||
<button type="submit" class="btn btn-primary" name="update">Update</button> | ||
</div> | ||
</form> | ||
</div> | ||
<div class="col-sm-6"> | ||
</div> | ||
|
||
</div> | ||
</div> | ||
|
||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php include_once("database.php"); | ||
|
||
$id = $_POST['id']; | ||
$fname = $_POST['fname']; | ||
$lname = $_POST['lname']; | ||
$pnum = $_POST['pnum']; | ||
|
||
$sql = "UPDATE userdata SET | ||
fname = '$fname', | ||
lname = '$lname', | ||
pnum = '$pnum' | ||
WHERE id=$id"; | ||
|
||
if ($con->query($sql) === TRUE) { | ||
//echo "Record updated successfully"; | ||
header("Location: index.php"); | ||
} else { | ||
echo "Error updating record: " . $con->error; | ||
} | ||
|
||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?php include_once("database.php"); | ||
|
||
$id = $_GET['id']; | ||
|
||
$sql = "SELECT * FROM userdata WHERE id=$id"; | ||
$result = $con->query($sql); | ||
foreach($result as $row){ | ||
$fname = $row['fname']; | ||
$lname = $row['lname']; | ||
$pnum = $row['pnum']; | ||
$con->close(); | ||
} | ||
?> | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<title>Viewing <?php echo $fname." ".$lname;?></title> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"> | ||
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/jquery.slim.min.js"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script> | ||
</head> | ||
<body> | ||
<nav class="navbar navbar-expand-sm bg-dark navbar-dark"> | ||
<ul class="navbar-nav"> | ||
<li class="nav-item"> | ||
<a class="nav-link" href="index.php">List</a> | ||
</li> | ||
<li class="nav-item"> | ||
<a class="nav-link" href="insert.html">Add New</a> | ||
</li> | ||
</ul> | ||
</nav> | ||
<div class="container"> | ||
<div class="row"> | ||
<div class="col-sm-6"> | ||
<div class="form-group"> | ||
<label for="usr">Name:</label> | ||
<label for="usr"><?php echo $fname." ".$lname;?></label> | ||
</div> | ||
<div class="form-group"> | ||
<label for="usr">Phone Number:</label> | ||
<label for="usr"><?php echo $pnum;?></label> | ||
</div> | ||
<div class="form-group"> | ||
<a href="delete.php?id=<?= $row['id'] ?>" class="btn btn-danger">Delete</a> | ||
<a href="update.php?id=<?= $row['id'] ?>" class="btn btn-primary">Update</a> | ||
</div> | ||
</div> | ||
<div class="col-sm-6"> | ||
</div> | ||
|
||
</div> | ||
</div> | ||
|
||
</body> | ||
</html> |