ScrollOfYin
Seiyuu Fanatic
2
MONTHS
2 2 MONTHS OF SERVICE
LEVEL 1
300 XP
If you are looking for Contact Information System then you are at the right place. I have a full source code of Contact Information System. This system works on how to add, update, and delete contact information.
We're gonna use INSERT, UPDATE, and DELETE Statement for this system using PDO.
INSERT, UPDATE, and DELETE Statement
INSERT Statement Using PDO
UPDATE Statement Using PDO
DELETE Statement Using PDO
Form Field
Add Form Field
Update Form Field
Delete Field
Result:
INSERT Data
UPDATE Data
DELETE Data
And, that's it. Kindly click the "Download Code" button below for full source code. Thank very much.
Share us your thoughts and comments below. Thank you so much for dropping by and reading this tutorial post. For more updates, don’t hesitate and feel free to visit this website more often and please share this with your friends or email me at [email protected]. Practice Coding. Thank you very much.
Download
We're gonna use INSERT, UPDATE, and DELETE Statement for this system using PDO.
INSERT, UPDATE, and DELETE Statement
INSERT Statement Using PDO
- <?php
- include
(
'db.php'
)
;
- $first_name
=
$_POST
[
'first_name'
]
;
- $last_name
=
$_POST
[
'last_name'
]
;
- $contact_number
=
$_POST
[
'contact_number'
]
;
- $email
=
$_POST
[
'email'
]
;
- $address
=
$_POST
[
'address'
]
;
- $conn
->
setAttribute
(
PDO::
ATTR_ERRMODE
,
PDO::
ERRMODE_EXCEPTION
)
;
- $sql
=
"INSERT INTO tbl_member (first_name, last_name, contact_number, email, address )
- VALUES ('$first_name
', '$last_name
', '$contact_number
', '$email
', '$address
')"
;
- $conn
->
exec
(
$sql
)
;
- echo
"<script>alert('Successfully Added!'); window.location='index.php'</script>"
;
- ?>
UPDATE Statement Using PDO
- <?php
- include
'db.php'
;
- $get_id
=
$_REQUEST
[
'tbl_member_id'
]
;
- $first_name
=
$_POST
[
'first_name'
]
;
- $last_name
=
$_POST
[
'last_name'
]
;
- $contact_number
=
$_POST
[
'contact_number'
]
;
- $email
=
$_POST
[
'email'
]
;
- $address
=
$_POST
[
'address'
]
;
- $sql
=
"UPDATE tbl_member SET first_name ='$first_name
', last_name ='$last_name
',
- contact_number ='$contact_number
', email ='$email
', address ='$address
' WHERE tbl_member_id = '$get_id
' "
;
- $conn
->
exec
(
$sql
)
;
- echo
"<script>alert('Successfully Edit The Account!'); window.location='index.php'</script>"
;
- ?>
DELETE Statement Using PDO
- <?php
- require_once
(
'db.php'
)
;
- $get_id
=
$_GET
[
'tbl_member_id'
]
;
- // sql to delete a record
- $sql
=
"Delete from tbl_member where tbl_member_id = '$get_id
'"
;
- // use exec() because no results are returned
- $conn
->
exec
(
$sql
)
;
- header
(
'location:index.php'
)
;
- ?>
Form Field
Add Form Field
- <form
method
=
"post"
action
=
"add_person_query.php"
>
- <table
border
=
"1"
cellspacing
=
"5"
cellpadding
=
"5"
width
=
"100%"
>
- <tr
>
- <td
>
- <label
>
First Name</
label
>
- </
td
>
- <td
width
=
"395px"
>
- <input
type
=
"text"
class
=
"text_Box"
name
=
"first_name"
autofocus=
"autofocus"
placeholder=
"First Name ....."
required /
>
- </
td
>
- </
tr
>
- <tr
>
- <td
>
- <label
>
Last Name</
label
>
- </
td
>
- <td
width
=
"395px"
>
- <input
type
=
"text"
class
=
"text_Box"
name
=
"last_name"
placeholder=
"Last Name ....."
required /
>
- </
td
>
- </
tr
>
- <tr
>
- <td
>
- <label
>
Contact Number</
label
>
- </
td
>
- <td
width
=
"395px"
>
- <input
type
=
"text"
class
=
"text_Box"
name
=
"contact_number"
placeholder=
"Contact Number ....."
required /
>
- </
td
>
- </
tr
>
- <tr
>
- <td
>
- <label
>
Email</
label
>
- </
td
>
- <td
width
=
"395px"
>
- <input
type
=
"email"
class
=
"text_Box"
name
=
"email"
placeholder=
"Email ....."
>
- </
td
>
- </
tr
>
- <tr
>
- <td
>
- <label
>
Address</
label
>
- </
td
>
- <td
width
=
"395px"
>
- <input
type
=
"text"
class
=
"text_Box"
name
=
"address"
placeholder=
"Address ....."
required /
>
- </
td
>
- </
tr
>
- <tr
>
- <td
colspan
=
"2"
>
- <a
>
- <button
type
=
"submit"
class
=
"btn_confirm"
>
- Save Data
- </
button
>
- </
a
>
- </
td
>
- </
tr
>
- </
table
>
- </
form
>
Update Form Field
- <?php
- include(
'db.php'
)
;
- $result =
$conn->
prepare("SELECT * FROM tbl_member where tbl_member_id='$ID'");
- $result->execute();
- for($i=0; $row = $result->fetch(); $i++){
- $id=$row['tbl_member_id'];
- ?>
- <form
method
=
"post"
action
=
"edit_person_query.php<?php echo '?tbl_member_id='.$id; ?>
">
- <table
border
=
"1"
cellspacing
=
"5"
cellpadding
=
"5"
width
=
"100%"
>
- <tr
>
- <td
>
- <label
>
First Name</
label
>
- </
td
>
- <td
width
=
"395px"
>
- <input
type
=
"text"
class
=
"text_Box"
name
=
"first_name"
value
=
"<?php echo $row['first_name']; ?>
" autofocus="autofocus" placeholder="First Name ....." />
- </
td
>
- </
tr
>
- <tr
>
- <td
>
- <label
>
Last Name</
label
>
- </
td
>
- <td
width
=
"395px"
>
- <input
type
=
"text"
class
=
"text_Box"
name
=
"last_name"
value
=
"<?php echo $row['last_name']; ?>
" placeholder="Last Name ....." />
- </
td
>
- </
tr
>
- <tr
>
- <td
>
- <label
>
Contact Number</
label
>
- </
td
>
- <td
width
=
"395px"
>
- <input
type
=
"text"
class
=
"text_Box"
name
=
"contact_number"
value
=
"<?php echo $row['contact_number']; ?>
" placeholder="Contact Number ....." />
- </
td
>
- </
tr
>
- <tr
>
- <td
>
- <label
>
Email</
label
>
- </
td
>
- <td
width
=
"395px"
>
- <input
type
=
"email"
class
=
"text_Box"
name
=
"email"
value
=
"<?php echo $row['email']; ?>
" placeholder="Email .....">
- </
td
>
- </
tr
>
- <tr
>
- <td
>
- <label
>
Address</
label
>
- </
td
>
- <td
width
=
"395px"
>
- <input
type
=
"text"
class
=
"text_Box"
name
=
"address"
value
=
"<?php echo $row['address']; ?>
" placeholder="Address ....." />
- </
td
>
- </
tr
>
- <tr
>
- <td
colspan
=
"2"
>
- <a
>
- <button
type
=
"submit"
class
=
"btn_confirm"
>
- Save Data
- </
button
>
- </
a
>
- </
td
>
- </
tr
>
- </
table
>
- </
form
>
- <?php }
?>
Delete Field
- <a
href
=
"delete_contact.php<?php echo '?tbl_member_id='.$id; ?>
">
- <button
type
=
"submit"
class
=
"btn_confirm1"
onclick
=
"return confirm(' Delete Contact ( <?php echo $first_name?>
) ? ');">
- Delete
- </
button
>
- </
a
>
Result:
INSERT Data

UPDATE Data

DELETE Data

And, that's it. Kindly click the "Download Code" button below for full source code. Thank very much.
Share us your thoughts and comments below. Thank you so much for dropping by and reading this tutorial post. For more updates, don’t hesitate and feel free to visit this website more often and please share this with your friends or email me at [email protected]. Practice Coding. Thank you very much.
Download
You must upgrade your account or reply in the thread to view hidden text.