-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrespond.php
141 lines (112 loc) · 4.91 KB
/
respond.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
<?php
/**
* TSW Details NanoBlog
* Author: Larry Judd Oliver @tradesouthwest | http://tradesouthwest.com/details
* Contributors in readme.md file
* License in LICENSE.md file
*/
include 'header.php';
?>
<title>Dev App for Looping Details</title>
<style>form{margin-left: 16px;}.control-label{padding-left: 8px;}</style>
</head>
<body>
<?php include 'nav.php'; ?><div class="clearfix"></div>
<div class="container">
<div class="row">
<header class="col-md-12">
<?php
if (isset($_POST['respond'])) {
$respond_to = filter_var( $_POST['respond_to'], FILTER_SANITIZE_STRING ); // title of article
$idd_is = filter_var( $_POST['idd_is'], FILTER_VALIDATE_INT ); // numeric id of article
} ?>
<h3 class="page-header"><small>Add Response to: <?php esc( $respond_to ); ?></small></h3>
<?php
if( isset( $_POST['submit_res'] )) {
$idd_is = filter_var( $_POST['idd_is'], FILTER_VALIDATE_INT );
$name = filter_var( $_POST['name'], FILTER_SANITIZE_STRING );
$email = filter_var( $_POST['email'], FILTER_VALIDATE_EMAIL );
$respond = filter_var( $_POST['respond'], FILTER_SANITIZE_STRING );
$date_inis = date( 'm/d/Y H:i' );
$date_respond = filter_var( $date_inis, FILTER_SANITIZE_STRING );
require_once 'inc/dbh.php';
$sql = "INSERT INTO tsw_respond
( idd_is, name, email, respond, date_respond )
VALUES ( :idd_is, :name, :email, :respond, :date_respond )";
//Prepare each statement.
$stmt = $dbh->prepare($sql);
//Bind the values to the parameters
$stmt->bindValue( ':idd_is', $idd_is );
$stmt->bindValue( ':name', $name );
$stmt->bindValue( ':email', $email );
$stmt->bindValue( ':respond', $respond );
$stmt->bindValue( ':date_respond', $date_respond );
//Execute the statement and insert values.
$inserted = $stmt->execute();
if( $inserted ){
?>
<br>
<div class="panel panel-success">
<div class="panel-heading">
<h3 class="panel-title">Data entered</h3>
</div>
<div class="panel-body">
Response Created Successfully! <br>
<?php print date('m-d-Y H:m'); ?>
<hr><p><form action="details.php?id=<?php esc( $idd_is ); ?>" method="POST"><input type="button" class='btn btn-success' onclick="submit()" name="success" value="BACK to Article"></form></p>
</div>
</div>
<br><div class="clearfix"</div>
<h3>Cool Results</h3>
<p>Entry added</p>
<a class="btn btn-primary-outline" href="index.php" role="button">View Home Page ←</a>
<?php
}
else {
print ( "Please retry" );
print_r( $inserted->errorInfo() );
}
}
?>
</header>
</div>
</div>
<div class="container">
<div class="row">
<div class="col-md-7">
<p><a href="javascript:history.back(0)" title="back to article" class="btn btn-default">Back to Article</a></p>
<form class="form-horizontal" name="responseform" role="form"
method="post" id="editForm" action="<?php echo $SERVER['PHP_SELF']; ?>">
<div class="form-group">
<label for="name" class="control-label">name</label><br>
<input type="text" class="form-control" id="name" name="name" placeholder="required" value="" required>
</div>
<div class="form-group">
<label for="email" class="control-label">email</label><br>
<input type="email" class="form-control" id="email" name="email" placeholder="email" value="" required>
</div>
<div class="form-group">
<label for="detail" class="control-label">respond </label><br>
<textarea name="respond" class="form-control" name="respond"></textarea>
</div>
<div class="form-group">
<label for="submit">date auto-inserted</label><br>
<input type="hidden" name="idd_is" value="<?php esc( $idd_is ); ?>">
<input id="submit" name="submit_res" type="submit" value="Add Reply" class="btn btn-primary">
</div>
</form>
</div><!-- ends col-7 -->
<div class="col-md-5 toppad">
<figure class="col-lg-4 bordered">
<img src="https://placeimg.com/420/380/any/sepia" class="img-responsive" alt="img"/>
</figure>
<figure class="col-lg-4 bordered">
<img src="https://placeimg.com/420/380/nature/sepia" class="img-responsive" alt="img"/>
</figure>
<figure class="col-lg-4 bordered">
<img src="https://placeimg.com/420/380/people/sepia" class="img-responsive" alt="img"/>
</figure>
</div>
</div>
</div>
<?php include 'footer.php'; ?>