Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
TB_Center
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Andry F. Hutapea
TB_Center
Commits
61758d3f
Commit
61758d3f
authored
May 25, 2017
by
Loni Miranda Doloksaribu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
In progress
parent
6959ee41
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
65 additions
and
0 deletions
+65
-0
add_apply.php
add_apply.php
+65
-0
No files found.
add_apply.php
0 → 100644
View file @
61758d3f
<link
href=
"css/animate1.css"
rel=
'stylesheet'
type=
'text/css'
/>
<ul
class=
"tp-hd-lft wow fadeInDown animated"
data-wow-delay=
"0.5s"
>
<?php
$host
=
"localhost"
;
// Host name
$username
=
"root"
;
// Mysql username
$password
=
""
;
// Mysql password
$db_name
=
"tiket"
;
// Database name
$tbl_name
=
"fapply"
;
// Table name
// Connect to server and select databse.
$conn
=
mysqli_connect
(
"
$host
"
,
"
$username
"
,
"
$password
"
)
or
die
(
"cannot connect"
);
mysqli_select_db
(
$conn
,
"
$db_name
"
)
or
die
(
"cannot select DB"
);
// Get value of id that sent from hidden field
$id
=
$_GET
[
'id'
];
// Find highest answer number.
$sql
=
"SELECT MAX(a_id) AS Maxa_id FROM
$tbl_name
WHERE question_id='
$id
'"
;
$result
=
mysqli_query
(
$conn
,
$sql
);
$rows
=
mysqli_fetch_array
(
$result
);
// add + 1 to highest answer number and keep it in variable name "$Max_id". if there no answer yet set it = 1
if
(
$rows
)
{
$Max_id
=
$rows
[
'Maxa_id'
]
+
1
;
}
else
{
$Max_id
=
1
;
}
// get values that sent from form
$a_name
=
$_POST
[
'a_name'
];
$a_email
=
$_POST
[
'a_email'
];
$a_answer
=
$_POST
[
'a_answer'
];
$datetime
=
date
(
"d/m/y H:i:s"
);
// create date and time
// Insert answer
$sql2
=
"INSERT INTO fapply(question_id, a_id, a_name, a_email, a_answer, a_datetime)VALUES('
$id
', '
$Max_id
', '
$a_name
', '
$a_email
', '
$a_answer
', '
$datetime
')"
;
$result2
=
mysqli_query
(
$conn
,
$sql2
);
if
(
$result2
){
echo
"Successful<BR>"
;
echo
"<a href='view_pemesanan.php?id="
.
$id
.
"'>View your answer</a>"
;
// If added new answer, add value +1 in reply column
$tbl_name2
=
"fpemesanan"
;
$sql3
=
"UPDATE
$tbl_name2
SET reply='
$Max_id
' WHERE id='
$id
'"
;
$result3
=
mysqli_query
(
$conn
,
$sql3
);
}
else
{
echo
$result2
;
echo
$id
.
"<br>"
;
echo
$a_name
.
"<br>"
;
echo
$a_email
.
"<br>"
;
echo
$a_answer
.
"<br>"
;
echo
$Max_id
.
"<br>"
;
echo
"ERROR"
;
}
// Close connection
//mysql_close();
?>
</ul>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment