Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
loka1 committed Dec 14, 2024
0 parents commit 200b2d4
Show file tree
Hide file tree
Showing 13 changed files with 743 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
screenshoots
56 changes: 56 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Todo List Application

This is a simple Todo List application built with PHP and MySQL. It allows users to manage their tasks efficiently by adding, updating, and deleting tasks.

## Features

- **Add Task**: Users can add new tasks to their todo list.
- **Update Task**: Users can update existing tasks.
- **Delete Task**: Users can delete tasks that are no longer needed.
- **Responsive Design**: The application uses Bootstrap for a responsive and modern design.

## Requirements

- PHP 7.0 or higher
- MySQL

## Installation

1. Clone the repository:
```sh
git clone https://github.com/yourusername/Todo-list-with-php.git
```
2. Navigate to the project directory:
```sh
cd Todo-list-with-php
```
3. Import the database:
```sh
mysql -u username -p database_name < database.sql
```
4. Configure the database connection in `db.php`.

## Usage

1. Start the PHP server:
```sh
php -S localhost:8000
```
2. Open your browser and go to `http://localhost:8000`.

## Contributing

Contributions are welcome! Please open an issue or submit a pull request.

## Credits

This application was designed and developed by:
- Asmaa El-Naggar
- Loka Shafik
- Hesham Yehia

Special thanks to Dr. Reham for her guidance and support throughout the project.

## License

This project is licensed under the MIT License.
62 changes: 62 additions & 0 deletions about.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?php
/*
* Include the header file
* This includes the header file, which contains the HTML head and opening body tags
*/
require_once 'header.php';
?>
<!-- Begin Bootstrap container-fluidfor the about section -->
<div class="container-fluidmt-5">
<!-- Begin Bootstrap row for the about section -->
<div class='row justify-content-center'>
<!-- Bootstrap column with full width on all screen sizes, centered text, and top margin -->
<div class='col-12 col-md-8'>
<!-- Bootstrap card for the about section -->
<div class="card">
<div class="card-header text-center">
<h1>About Us</h1>
</div>
<div class="card-body">
<!-- Paragraph describing the purpose and functionality of the application -->
<p class="card-text">This application is a To-Do List that helps you manage and save your tasks efficiently. You can add, update, and delete tasks as needed, ensuring that you stay organized and on top of your responsibilities.</p>
<!-- Paragraph introducing the designers of the website -->
<p class="card-text">This website was designed by:</p>
<!-- Table of the designers' names -->
<table class="table table-bordered">
<thead>
<tr>
<th>Designers</th>
</tr>
</thead>
<tbody>
<tr>
<td>Asmaa El-Naggar</td>
</tr>
<tr>
<td>Loka Shafik</td>
</tr>
<tr>
<td>Hesham Yehia</td>
</tr>
</tbody>
</table>
<!-- Paragraph mentioning the supervision of Dr. Reham -->
<p class="card-text">Under the supervision of <strong style="color: blue;">Dr. Reham</strong>.</p>
<!-- Paragraph giving special thanks to Dr. Reham -->
<p class="card-text">Special thanks to <strong style="color: blue;">Dr. Reham</strong> for her guidance and support throughout the project.</p>
</div>
</div>
</div>
</div>
<!-- End Bootstrap row for the about section -->
</div>
<!-- End Bootstrap container-fluidfor the about section -->

<?php
/*
* Include the footer file
* This includes the footer file, which contains the js scripts and ending body tags
*/
require_once 'footer.php';
?>

41 changes: 41 additions & 0 deletions add.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php
// Start the session to use session variables
session_start(); // This initializes a session, allowing you to store and retrieve data across multiple pages

// Include the header file
require_once "header.php"; // This includes the header file, which contains the HTML head and opening body tags
?>

<div class="container-fluidmt-5">
<div class="row justify-content-center">
<div class="col-12 col-md-8">
<!-- Bootstrap card for the add task form -->
<div class="card">
<div class="card-header text-center">
<h2>Add New Task</h2>
</div>
<div class="card-body">
<!-- Form to add a new task -->
<form action="index_valid.php" method="post">
<div class="form-group">
<!-- Input field for entering a new task -->
<input class="form-control form-control-lg" type="text" name="textfield" placeholder="Enter your task">
</div>
<div class="form-group">
<!-- Submit button to add the task -->
<input class="btn btn-success btn-block" type="submit" name="addtask" value="Add Task">
</div>
</form>
</div>
</div>
</div>
</div>
</div>

<?php
/*
* Include the footer file
* This includes the footer file, which contains the js scripts and ending body tags
*/
require_once 'footer.php';
?>
Binary file added background.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
45 changes: 45 additions & 0 deletions db.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php
/*
* Define the database host
* This constant defines the hostname of the database server
*/
const HOST = 'localhost';

/*
* Define the database username
* This constant defines the username used to connect to the database
*/
const USERNAME = 'user_name';

/*
* Define the database password
* This constant defines the password used to connect to the database
*/
const PASSWORD = 'password';

/*
* Define the database name
* This constant defines the name of the database to connect to
*/
const DBNAME = 'todo_app';

/*
* Create a new MySQLi connection
* This creates a new connection to the MySQL database using the defined constants
*/
$dbcon = new mysqli(HOST, USERNAME, PASSWORD, DBNAME);

/*
* Check if the connection has any errors
* This checks if there was an error while trying to connect to the database
*/
if ($dbcon->connect_error) {
/*
* Terminate the script if there is a connection error
* This terminates the script and outputs an error message if the connection fails
*/
die("connect error: " . $dbcon->connect_error);
}
// Set the character set to utf8mb4
$dbcon->set_charset("utf8mb4");
?>
73 changes: 73 additions & 0 deletions delete.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<?php
/*
* Start the session to use session variables
* This initializes a session, allowing you to store and retrieve data across multiple pages
*/
session_start();

/*
* Include the database connection file
* This includes the database connection file, allowing you to use the $dbcon variable for database operations
*/
require_once "db.php";

/*
* Check if the 'id' parameter is set in the URL
* This checks if the 'id' parameter is present in the URL, ensuring that we have an ID to work with
*/
if (isset($_GET['id'])) {
/*
* Decode the base64 encoded 'id' parameter from the URL
* This decodes the base64 encoded 'id' parameter from the URL to get the original ID value
*/
$id = base64_decode($_GET['id']);

/*
* Create the SQL query to delete the task with the specified id
* This creates an SQL query to delete the task with the specified ID from the task_table
*/
$delete_query = "DELETE FROM task_table WHERE id=$id";

/*
* This line is redundant and does nothing
* This line is unnecessary and does not affect the code execution
*/
$delete_query;

/*
* Execute the delete query using the database connection
* This executes the delete query using the database connection
*/
$run_query = $dbcon->query($delete_query);

/*
* Check if the query was executed successfully
* This checks if the query was executed successfully
*/
if($run_query){
/*
* Set a session variable to indicate successful deletion
* This sets a session variable to indicate that the task was deleted successfully
*/
$_SESSION['delete_success'] = "Task delete successfully";
}

/*
* Redirect to the index.php page after deletion
* This redirects the user to the index.php page after the deletion
*/
header('location: index.php');
}
/*
* If the 'id' parameter is not set in the URL
* This block executes if the 'id' parameter is not set in the URL
*/
else{
/*
* Redirect to the index.php page
* This redirects the user to the index.php page if no 'id' parameter is found
*/
header('location: index.php');
}

?>
19 changes: 19 additions & 0 deletions footer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

</div>
<!-- Simple footer with copyright and links -->
<footer class="bg-dark text-white text-center py-3 mt-5">
<ul class="list-inline">
<li class="list-inline-item"><a class="text-white" href="index.php">Home</a></li>
<li class="list-inline-item"><a class="text-white" href="add.php">Add Task</a></li>
<li class="list-inline-item"><a class="text-white" href="about.php">About</a></li>
</ul>
<p>&copy; 2024 Todo List Application. All rights reserved.</p>
<p>Special thanks to <strong style="color: blue;">Dr. Reham</strong> for her guidance and support.</p>
</footer>

<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.14.7/dist/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.3.1/dist/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
<!-- Close the body and html tags -->
</body>
</html>
Loading

0 comments on commit 200b2d4

Please sign in to comment.