SlideShare a Scribd company logo
Hello I need help getting my delete and additem button to work. The delete button needs to use
the file delete_record.php and the add item button needs to use the file add_item.php.. The
problem I am running into is that neither button is wanting to post anything. The AddItem button
needs to post new information to an sql server called todolistand a table named todoitems. The
delete button needs to delete those records if the user so wishes from the database. Each time the
button is clicked it should send the user back to the index.php page. The todolist and todoitems
have the followers columns ItenNum - int(11), Title - varchar(20), and Description - varchar(50).
Below is the files I need fixed.
Index.php:
<?php
require('database.php');
//post data
$newTitle = filter_input(INPUT_POST, 'newTitle', FILTER_UNSAFE_RAW);
$description = filter_input(INPUT_POST, 'description', FILTER_UNSAFE_RAW);
//Get Data
$title = filter_input(INPUT_GET, 'tile', FILTER_UNSAFE_RAW);
$query = 'SELECT * FROM todoitems';// PUT YOUR SQL QUERY HERE
// Example: $query = 'SELECT * FROM customers';
$statement = $db->prepare($query);
$statement->execute();
$results = $statement->fetchAll();
$statement->closeCursor();
?>
<!DOCTYPE html>
<hmtl lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-wdith, inital-scale=1.0">
<Title>ToDoList</title>
</head>
<body>
<main>
<header>
<h1>ToDoList</h1>
</header>
<?php if(!empty($results)){ ?>
<section>
<?php foreach ($results as $results) : ?>
<p><span class="bold">Title:</span> <?php echo $results['Title']; ?></p>
<p><span class="bold">Description:</span> <?php echo $results['Description']; ?></p>
<form action ="delete_record.php" method="POST">
<input type="hidden" name = "id" value="<?php echo $itenNum ?>">
<button>Delete</button>
<?php endforeach; ?>
</section>
<?php } else {?>
<p>Sorry No Results!</p>
<?php } ?>
<h2>Add Item:</h2>
<form method ="post">
<label for="title">Title:</label>
<input type = "text" id="title" name="title" required>
<label for="description">Description:</label>
<textarea id ="description" name="description" required></textarea>
<button type = "submit">Add Item</button>
</main>
</body>
</html>
database.php:
<?php
$dsn ="mysql:host=localhost; dbname=ToDoList";
$username = 'root';
$password = '4895698As';
try
{
$db = new PDO($dsn, $username, $password);
} catch (PDOException $e)
{
$error_message = 'Database Error!';
$error_message .= $e->getMessage();
echo $error_message;
exit();
}
?>
add_item.php:
<?php
require("database.php");
// Check if the form has been submitted
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
// Retrieve the form data
$title = $_POST['title'];
$description = $_POST['description'];
// Insert the new item into the todoitems table
$query = "INSERT INTO todoitems (Title, Description) VALUES (:title, :description)";
$statement = $db->prepare($query);
$statement->bindValue(':title', $title);
$statement->bindValue(':description', $description);
$statement->execute();
// Redirect the user to the index page
header('Location: index.php');
exit();
}
include("index.php");
?>
delete_record.php:
<?php
require_once('database.php');
// here Check if the ItemNum parameter has been passed
if (!isset($_GET['ItemNum'])) {
header('Location: index.php');
exit();
}
// Retrieve the ItemNum parameter.
$itemNum = $_GET['ItemNum'];
// Delete the item from todoitems.
$query = "DELETE FROM todoitems WHERE ItemNum = :itemNum";
$statement = $db->prepare($query);
$statement->bindValue(':itemNum', $itemNum);
$statement->execute();
// Redirect the user to the index page
header('Location: index.php');
exit();
include("index.php");
?>
Hello I need help getting my delete and additem button to work- The de.pdf

More Related Content

Similar to Hello I need help getting my delete and additem button to work- The de.pdf

Wordpress plugin development from Scratch
Wordpress plugin development from ScratchWordpress plugin development from Scratch
Wordpress plugin development from Scratch
Ocaka Alfred
 
Your Custom WordPress Admin Pages Suck
Your Custom WordPress Admin Pages SuckYour Custom WordPress Admin Pages Suck
Your Custom WordPress Admin Pages Suck
Anthony Montalbano
 
Creating web api and consuming part 2
Creating web api and consuming part 2Creating web api and consuming part 2
Creating web api and consuming part 2
Dipendra Shekhawat
 
Un-Framework - Delivering Dynamic Experiences with HTML over the Wire
Un-Framework - Delivering Dynamic Experiences with HTML over the WireUn-Framework - Delivering Dynamic Experiences with HTML over the Wire
Un-Framework - Delivering Dynamic Experiences with HTML over the Wire
Andreas Nedbal
 
Web development today
Web development todayWeb development today
Web development today
Hesham Amin
 
PHP webboard
PHP webboardPHP webboard
PHP webboard
tumetr1
 
Slimme Joomla! Templating Tips en Truuks
Slimme Joomla! Templating Tips en TruuksSlimme Joomla! Templating Tips en Truuks
Slimme Joomla! Templating Tips en Truuks
ThemePartner
 
Ex[1].3 php db connectivity
Ex[1].3 php db connectivityEx[1].3 php db connectivity
Ex[1].3 php db connectivity
Mouli Chandira
 
Practical PHP by example Jan Leth-Kjaer
Practical PHP by example   Jan Leth-KjaerPractical PHP by example   Jan Leth-Kjaer
Practical PHP by example Jan Leth-Kjaer
COMMON Europe
 
Add row in asp.net Gridview on button click using C# and vb.net
Add row in asp.net Gridview on button click using C# and vb.netAdd row in asp.net Gridview on button click using C# and vb.net
Add row in asp.net Gridview on button click using C# and vb.net
Vijay Saklani
 
Add row in asp.net Gridview on button click using C# and vb.net
Add row in asp.net Gridview on button click using C# and vb.netAdd row in asp.net Gridview on button click using C# and vb.net
Add row in asp.net Gridview on button click using C# and vb.net
Vijay Saklani
 
16-DOMTree.pptx
16-DOMTree.pptx16-DOMTree.pptx
16-DOMTree.pptx
KhushiSingla10
 
I211 – Information Infrastructure IILecture 20TodayCGI.docx
I211 – Information Infrastructure IILecture 20TodayCGI.docxI211 – Information Infrastructure IILecture 20TodayCGI.docx
I211 – Information Infrastructure IILecture 20TodayCGI.docx
florriezhamphrey3065
 
Web осень 2012 лекция 7
Web осень 2012 лекция 7Web осень 2012 лекция 7
Web осень 2012 лекция 7
Technopark
 
04 Html Form Get Post Login System
04 Html Form Get Post Login System04 Html Form Get Post Login System
04 Html Form Get Post Login System
Geshan Manandhar
 
I need help on figuring out how to chop up my controller for MVC int.pdf
I need help on figuring out how to chop up my controller for MVC int.pdfI need help on figuring out how to chop up my controller for MVC int.pdf
I need help on figuring out how to chop up my controller for MVC int.pdf
allurafashions98
 
How to Create A Magento Adminhtml Controller in Magento Extension
How to Create A Magento Adminhtml Controller in Magento ExtensionHow to Create A Magento Adminhtml Controller in Magento Extension
How to Create A Magento Adminhtml Controller in Magento Extension
Hendy Irawan
 
Database connectivity in PHP
Database connectivity in PHPDatabase connectivity in PHP
Database connectivity in PHP
Vineet Kumar Saini
 
Django
DjangoDjango
Django
Ivan Widodo
 
Clever Joomla! Templating Tips and Tricks
Clever Joomla! Templating Tips and TricksClever Joomla! Templating Tips and Tricks
Clever Joomla! Templating Tips and Tricks
ThemePartner
 

Similar to Hello I need help getting my delete and additem button to work- The de.pdf (20)

Wordpress plugin development from Scratch
Wordpress plugin development from ScratchWordpress plugin development from Scratch
Wordpress plugin development from Scratch
 
Your Custom WordPress Admin Pages Suck
Your Custom WordPress Admin Pages SuckYour Custom WordPress Admin Pages Suck
Your Custom WordPress Admin Pages Suck
 
Creating web api and consuming part 2
Creating web api and consuming part 2Creating web api and consuming part 2
Creating web api and consuming part 2
 
Un-Framework - Delivering Dynamic Experiences with HTML over the Wire
Un-Framework - Delivering Dynamic Experiences with HTML over the WireUn-Framework - Delivering Dynamic Experiences with HTML over the Wire
Un-Framework - Delivering Dynamic Experiences with HTML over the Wire
 
Web development today
Web development todayWeb development today
Web development today
 
PHP webboard
PHP webboardPHP webboard
PHP webboard
 
Slimme Joomla! Templating Tips en Truuks
Slimme Joomla! Templating Tips en TruuksSlimme Joomla! Templating Tips en Truuks
Slimme Joomla! Templating Tips en Truuks
 
Ex[1].3 php db connectivity
Ex[1].3 php db connectivityEx[1].3 php db connectivity
Ex[1].3 php db connectivity
 
Practical PHP by example Jan Leth-Kjaer
Practical PHP by example   Jan Leth-KjaerPractical PHP by example   Jan Leth-Kjaer
Practical PHP by example Jan Leth-Kjaer
 
Add row in asp.net Gridview on button click using C# and vb.net
Add row in asp.net Gridview on button click using C# and vb.netAdd row in asp.net Gridview on button click using C# and vb.net
Add row in asp.net Gridview on button click using C# and vb.net
 
Add row in asp.net Gridview on button click using C# and vb.net
Add row in asp.net Gridview on button click using C# and vb.netAdd row in asp.net Gridview on button click using C# and vb.net
Add row in asp.net Gridview on button click using C# and vb.net
 
16-DOMTree.pptx
16-DOMTree.pptx16-DOMTree.pptx
16-DOMTree.pptx
 
I211 – Information Infrastructure IILecture 20TodayCGI.docx
I211 – Information Infrastructure IILecture 20TodayCGI.docxI211 – Information Infrastructure IILecture 20TodayCGI.docx
I211 – Information Infrastructure IILecture 20TodayCGI.docx
 
Web осень 2012 лекция 7
Web осень 2012 лекция 7Web осень 2012 лекция 7
Web осень 2012 лекция 7
 
04 Html Form Get Post Login System
04 Html Form Get Post Login System04 Html Form Get Post Login System
04 Html Form Get Post Login System
 
I need help on figuring out how to chop up my controller for MVC int.pdf
I need help on figuring out how to chop up my controller for MVC int.pdfI need help on figuring out how to chop up my controller for MVC int.pdf
I need help on figuring out how to chop up my controller for MVC int.pdf
 
How to Create A Magento Adminhtml Controller in Magento Extension
How to Create A Magento Adminhtml Controller in Magento ExtensionHow to Create A Magento Adminhtml Controller in Magento Extension
How to Create A Magento Adminhtml Controller in Magento Extension
 
Database connectivity in PHP
Database connectivity in PHPDatabase connectivity in PHP
Database connectivity in PHP
 
Django
DjangoDjango
Django
 
Clever Joomla! Templating Tips and Tricks
Clever Joomla! Templating Tips and TricksClever Joomla! Templating Tips and Tricks
Clever Joomla! Templating Tips and Tricks
 

More from Ian0J2Bondo

Results and Observations Growth on slant- Describe the growth on your (1).pdf
Results and Observations Growth on slant- Describe the growth on your (1).pdfResults and Observations Growth on slant- Describe the growth on your (1).pdf
Results and Observations Growth on slant- Describe the growth on your (1).pdf
Ian0J2Bondo
 
Restaurateur Denny Valentine is evaluating two sites- Raymondville and.pdf
Restaurateur Denny Valentine is evaluating two sites- Raymondville and.pdfRestaurateur Denny Valentine is evaluating two sites- Raymondville and.pdf
Restaurateur Denny Valentine is evaluating two sites- Raymondville and.pdf
Ian0J2Bondo
 
Resource governance means that a container has access only to a specif.pdf
Resource governance means that a container has access only to a specif.pdfResource governance means that a container has access only to a specif.pdf
Resource governance means that a container has access only to a specif.pdf
Ian0J2Bondo
 
Respond to the following in a minimum of 175 words- Analyze the risks.pdf
Respond to the following in a minimum of 175 words-  Analyze the risks.pdfRespond to the following in a minimum of 175 words-  Analyze the risks.pdf
Respond to the following in a minimum of 175 words- Analyze the risks.pdf
Ian0J2Bondo
 
Researchers investigate the association between the rate of hospitalza.pdf
Researchers investigate the association between the rate of hospitalza.pdfResearchers investigate the association between the rate of hospitalza.pdf
Researchers investigate the association between the rate of hospitalza.pdf
Ian0J2Bondo
 
Researchers found that a person in a particular country spent an avera.pdf
Researchers found that a person in a particular country spent an avera.pdfResearchers found that a person in a particular country spent an avera.pdf
Researchers found that a person in a particular country spent an avera.pdf
Ian0J2Bondo
 
Research the relationship between the cardiac vector and the ECG signa.pdf
Research the relationship between the cardiac vector and the ECG signa.pdfResearch the relationship between the cardiac vector and the ECG signa.pdf
Research the relationship between the cardiac vector and the ECG signa.pdf
Ian0J2Bondo
 
Research Subject Datacenters have evolved over time to handle differen.pdf
Research Subject Datacenters have evolved over time to handle differen.pdfResearch Subject Datacenters have evolved over time to handle differen.pdf
Research Subject Datacenters have evolved over time to handle differen.pdf
Ian0J2Bondo
 
Research the USA and Canadian responses to COVID-19 and complete the f.pdf
Research the USA and Canadian responses to COVID-19 and complete the f.pdfResearch the USA and Canadian responses to COVID-19 and complete the f.pdf
Research the USA and Canadian responses to COVID-19 and complete the f.pdf
Ian0J2Bondo
 
Research Paper You will select a topic pertinent to the course subject.pdf
Research Paper You will select a topic pertinent to the course subject.pdfResearch Paper You will select a topic pertinent to the course subject.pdf
Research Paper You will select a topic pertinent to the course subject.pdf
Ian0J2Bondo
 
Research and discuss 4 other mammalian reflexes other than the mention.pdf
Research and discuss 4 other mammalian reflexes other than the mention.pdfResearch and discuss 4 other mammalian reflexes other than the mention.pdf
Research and discuss 4 other mammalian reflexes other than the mention.pdf
Ian0J2Bondo
 
Requirements- 1 Post the unadjusted balances of Daily Driver Inc- to t.pdf
Requirements- 1 Post the unadjusted balances of Daily Driver Inc- to t.pdfRequirements- 1 Post the unadjusted balances of Daily Driver Inc- to t.pdf
Requirements- 1 Post the unadjusted balances of Daily Driver Inc- to t.pdf
Ian0J2Bondo
 
Requirement 1- Prepare the April income statement under absorption cos.pdf
Requirement 1- Prepare the April income statement under absorption cos.pdfRequirement 1- Prepare the April income statement under absorption cos.pdf
Requirement 1- Prepare the April income statement under absorption cos.pdf
Ian0J2Bondo
 
Required- a) What amount of gain or loss does Ramona realize on the fo.pdf
Required- a) What amount of gain or loss does Ramona realize on the fo.pdfRequired- a) What amount of gain or loss does Ramona realize on the fo.pdf
Required- a) What amount of gain or loss does Ramona realize on the fo.pdf
Ian0J2Bondo
 
Required information Use the following information for the Quick Studi.pdf
Required information Use the following information for the Quick Studi.pdfRequired information Use the following information for the Quick Studi.pdf
Required information Use the following information for the Quick Studi.pdf
Ian0J2Bondo
 
Required information Use the followlng lnformetlon for the Exerclses b.pdf
Required information Use the followlng lnformetlon for the Exerclses b.pdfRequired information Use the followlng lnformetlon for the Exerclses b.pdf
Required information Use the followlng lnformetlon for the Exerclses b.pdf
Ian0J2Bondo
 
Required information The lifetime of a lightbulb in a certain applicat (1).pdf
Required information The lifetime of a lightbulb in a certain applicat (1).pdfRequired information The lifetime of a lightbulb in a certain applicat (1).pdf
Required information The lifetime of a lightbulb in a certain applicat (1).pdf
Ian0J2Bondo
 
Required information Shown below are the maps of a series of ril delet.pdf
Required information Shown below are the maps of a series of ril delet.pdfRequired information Shown below are the maps of a series of ril delet.pdf
Required information Shown below are the maps of a series of ril delet.pdf
Ian0J2Bondo
 
Required information Reporting Amounts on the Four Basic Financial Sta.pdf
Required information Reporting Amounts on the Four Basic Financial Sta.pdfRequired information Reporting Amounts on the Four Basic Financial Sta.pdf
Required information Reporting Amounts on the Four Basic Financial Sta.pdf
Ian0J2Bondo
 
Required information E6-17 (Algo) Analyzing Gross Profit Percentage on.pdf
Required information E6-17 (Algo) Analyzing Gross Profit Percentage on.pdfRequired information E6-17 (Algo) Analyzing Gross Profit Percentage on.pdf
Required information E6-17 (Algo) Analyzing Gross Profit Percentage on.pdf
Ian0J2Bondo
 

More from Ian0J2Bondo (20)

Results and Observations Growth on slant- Describe the growth on your (1).pdf
Results and Observations Growth on slant- Describe the growth on your (1).pdfResults and Observations Growth on slant- Describe the growth on your (1).pdf
Results and Observations Growth on slant- Describe the growth on your (1).pdf
 
Restaurateur Denny Valentine is evaluating two sites- Raymondville and.pdf
Restaurateur Denny Valentine is evaluating two sites- Raymondville and.pdfRestaurateur Denny Valentine is evaluating two sites- Raymondville and.pdf
Restaurateur Denny Valentine is evaluating two sites- Raymondville and.pdf
 
Resource governance means that a container has access only to a specif.pdf
Resource governance means that a container has access only to a specif.pdfResource governance means that a container has access only to a specif.pdf
Resource governance means that a container has access only to a specif.pdf
 
Respond to the following in a minimum of 175 words- Analyze the risks.pdf
Respond to the following in a minimum of 175 words-  Analyze the risks.pdfRespond to the following in a minimum of 175 words-  Analyze the risks.pdf
Respond to the following in a minimum of 175 words- Analyze the risks.pdf
 
Researchers investigate the association between the rate of hospitalza.pdf
Researchers investigate the association between the rate of hospitalza.pdfResearchers investigate the association between the rate of hospitalza.pdf
Researchers investigate the association between the rate of hospitalza.pdf
 
Researchers found that a person in a particular country spent an avera.pdf
Researchers found that a person in a particular country spent an avera.pdfResearchers found that a person in a particular country spent an avera.pdf
Researchers found that a person in a particular country spent an avera.pdf
 
Research the relationship between the cardiac vector and the ECG signa.pdf
Research the relationship between the cardiac vector and the ECG signa.pdfResearch the relationship between the cardiac vector and the ECG signa.pdf
Research the relationship between the cardiac vector and the ECG signa.pdf
 
Research Subject Datacenters have evolved over time to handle differen.pdf
Research Subject Datacenters have evolved over time to handle differen.pdfResearch Subject Datacenters have evolved over time to handle differen.pdf
Research Subject Datacenters have evolved over time to handle differen.pdf
 
Research the USA and Canadian responses to COVID-19 and complete the f.pdf
Research the USA and Canadian responses to COVID-19 and complete the f.pdfResearch the USA and Canadian responses to COVID-19 and complete the f.pdf
Research the USA and Canadian responses to COVID-19 and complete the f.pdf
 
Research Paper You will select a topic pertinent to the course subject.pdf
Research Paper You will select a topic pertinent to the course subject.pdfResearch Paper You will select a topic pertinent to the course subject.pdf
Research Paper You will select a topic pertinent to the course subject.pdf
 
Research and discuss 4 other mammalian reflexes other than the mention.pdf
Research and discuss 4 other mammalian reflexes other than the mention.pdfResearch and discuss 4 other mammalian reflexes other than the mention.pdf
Research and discuss 4 other mammalian reflexes other than the mention.pdf
 
Requirements- 1 Post the unadjusted balances of Daily Driver Inc- to t.pdf
Requirements- 1 Post the unadjusted balances of Daily Driver Inc- to t.pdfRequirements- 1 Post the unadjusted balances of Daily Driver Inc- to t.pdf
Requirements- 1 Post the unadjusted balances of Daily Driver Inc- to t.pdf
 
Requirement 1- Prepare the April income statement under absorption cos.pdf
Requirement 1- Prepare the April income statement under absorption cos.pdfRequirement 1- Prepare the April income statement under absorption cos.pdf
Requirement 1- Prepare the April income statement under absorption cos.pdf
 
Required- a) What amount of gain or loss does Ramona realize on the fo.pdf
Required- a) What amount of gain or loss does Ramona realize on the fo.pdfRequired- a) What amount of gain or loss does Ramona realize on the fo.pdf
Required- a) What amount of gain or loss does Ramona realize on the fo.pdf
 
Required information Use the following information for the Quick Studi.pdf
Required information Use the following information for the Quick Studi.pdfRequired information Use the following information for the Quick Studi.pdf
Required information Use the following information for the Quick Studi.pdf
 
Required information Use the followlng lnformetlon for the Exerclses b.pdf
Required information Use the followlng lnformetlon for the Exerclses b.pdfRequired information Use the followlng lnformetlon for the Exerclses b.pdf
Required information Use the followlng lnformetlon for the Exerclses b.pdf
 
Required information The lifetime of a lightbulb in a certain applicat (1).pdf
Required information The lifetime of a lightbulb in a certain applicat (1).pdfRequired information The lifetime of a lightbulb in a certain applicat (1).pdf
Required information The lifetime of a lightbulb in a certain applicat (1).pdf
 
Required information Shown below are the maps of a series of ril delet.pdf
Required information Shown below are the maps of a series of ril delet.pdfRequired information Shown below are the maps of a series of ril delet.pdf
Required information Shown below are the maps of a series of ril delet.pdf
 
Required information Reporting Amounts on the Four Basic Financial Sta.pdf
Required information Reporting Amounts on the Four Basic Financial Sta.pdfRequired information Reporting Amounts on the Four Basic Financial Sta.pdf
Required information Reporting Amounts on the Four Basic Financial Sta.pdf
 
Required information E6-17 (Algo) Analyzing Gross Profit Percentage on.pdf
Required information E6-17 (Algo) Analyzing Gross Profit Percentage on.pdfRequired information E6-17 (Algo) Analyzing Gross Profit Percentage on.pdf
Required information E6-17 (Algo) Analyzing Gross Profit Percentage on.pdf
 

Recently uploaded

The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
RitikBhardwaj56
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
thanhdowork
 
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
Priyankaranawat4
 
How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
Celine George
 
Digital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental DesignDigital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental Design
amberjdewit93
 
The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collectionThe Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
Israel Genealogy Research Association
 
The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
History of Stoke Newington
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
Priyankaranawat4
 
PIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf IslamabadPIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf Islamabad
AyyanKhan40
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
eBook.com.bd (প্রয়োজনীয় বাংলা বই)
 
How to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP ModuleHow to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP Module
Celine George
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
camakaiclarkmusic
 
Main Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docxMain Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docx
adhitya5119
 
Advanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docxAdvanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docx
adhitya5119
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
David Douglas School District
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
Nicholas Montgomery
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
TechSoup
 
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat  Leveraging AI for Diversity, Equity, and InclusionExecutive Directors Chat  Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
TechSoup
 
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama UniversityNatural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Akanksha trivedi rama nursing college kanpur.
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
Dr. Shivangi Singh Parihar
 

Recently uploaded (20)

The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
 
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
 
How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
 
Digital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental DesignDigital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental Design
 
The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collectionThe Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
 
The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
 
PIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf IslamabadPIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf Islamabad
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
 
How to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP ModuleHow to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP Module
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
 
Main Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docxMain Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docx
 
Advanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docxAdvanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docx
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
 
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat  Leveraging AI for Diversity, Equity, and InclusionExecutive Directors Chat  Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
 
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama UniversityNatural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
 

Hello I need help getting my delete and additem button to work- The de.pdf

  • 1. Hello I need help getting my delete and additem button to work. The delete button needs to use the file delete_record.php and the add item button needs to use the file add_item.php.. The problem I am running into is that neither button is wanting to post anything. The AddItem button needs to post new information to an sql server called todolistand a table named todoitems. The delete button needs to delete those records if the user so wishes from the database. Each time the button is clicked it should send the user back to the index.php page. The todolist and todoitems have the followers columns ItenNum - int(11), Title - varchar(20), and Description - varchar(50). Below is the files I need fixed. Index.php: <?php require('database.php'); //post data $newTitle = filter_input(INPUT_POST, 'newTitle', FILTER_UNSAFE_RAW); $description = filter_input(INPUT_POST, 'description', FILTER_UNSAFE_RAW); //Get Data $title = filter_input(INPUT_GET, 'tile', FILTER_UNSAFE_RAW); $query = 'SELECT * FROM todoitems';// PUT YOUR SQL QUERY HERE // Example: $query = 'SELECT * FROM customers'; $statement = $db->prepare($query); $statement->execute(); $results = $statement->fetchAll(); $statement->closeCursor(); ?> <!DOCTYPE html> <hmtl lang="en"> <head> <meta charset="UTF-8">
  • 2. <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-wdith, inital-scale=1.0"> <Title>ToDoList</title> </head> <body> <main> <header> <h1>ToDoList</h1> </header> <?php if(!empty($results)){ ?> <section> <?php foreach ($results as $results) : ?> <p><span class="bold">Title:</span> <?php echo $results['Title']; ?></p> <p><span class="bold">Description:</span> <?php echo $results['Description']; ?></p> <form action ="delete_record.php" method="POST"> <input type="hidden" name = "id" value="<?php echo $itenNum ?>"> <button>Delete</button> <?php endforeach; ?> </section> <?php } else {?> <p>Sorry No Results!</p> <?php } ?>
  • 3. <h2>Add Item:</h2> <form method ="post"> <label for="title">Title:</label> <input type = "text" id="title" name="title" required> <label for="description">Description:</label> <textarea id ="description" name="description" required></textarea> <button type = "submit">Add Item</button> </main> </body> </html> database.php: <?php $dsn ="mysql:host=localhost; dbname=ToDoList"; $username = 'root'; $password = '4895698As'; try { $db = new PDO($dsn, $username, $password); } catch (PDOException $e) { $error_message = 'Database Error!'; $error_message .= $e->getMessage(); echo $error_message;
  • 4. exit(); } ?> add_item.php: <?php require("database.php"); // Check if the form has been submitted if ($_SERVER['REQUEST_METHOD'] == 'POST') { // Retrieve the form data $title = $_POST['title']; $description = $_POST['description']; // Insert the new item into the todoitems table $query = "INSERT INTO todoitems (Title, Description) VALUES (:title, :description)"; $statement = $db->prepare($query); $statement->bindValue(':title', $title); $statement->bindValue(':description', $description); $statement->execute(); // Redirect the user to the index page header('Location: index.php'); exit(); }
  • 5. include("index.php"); ?> delete_record.php: <?php require_once('database.php'); // here Check if the ItemNum parameter has been passed if (!isset($_GET['ItemNum'])) { header('Location: index.php'); exit(); } // Retrieve the ItemNum parameter. $itemNum = $_GET['ItemNum']; // Delete the item from todoitems. $query = "DELETE FROM todoitems WHERE ItemNum = :itemNum"; $statement = $db->prepare($query); $statement->bindValue(':itemNum', $itemNum); $statement->execute(); // Redirect the user to the index page header('Location: index.php'); exit(); include("index.php"); ?>