This repository has been archived by the owner on Jul 13, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathtestimonial.php
126 lines (120 loc) · 5.43 KB
/
testimonial.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
<?php
/**
* @package Script Pulsa Online
* @version 1
* @author Engky Datz
* @link http://okepulsa.id
* @link http://facebook.com/Engky09
* @link http://okepulsa.id
* @link https://www.bukalapak.com/engky09
* @copyright 2015 -2016
*/
include ('includes/base.php');
$page_title = 'Testimonial | ' . $set['site_name'];
$active_page = 'testimonial';
$nama = isset($_POST['nama']) ? trim($_POST['nama']) : '';
$no_hp = isset($_POST['no_hp']) ? trim($_POST['no_hp']) : '';
$pesan = isset($_POST['pesan']) ? trim($_POST['pesan']) : '';
$kode = isset($_POST['kode']) ? trim($_POST['kode']) : '';
if (isset($_POST['submit']) && !isset($_SESSION['testi']))
{
$err = array();
if (strlen($nama) > 12 || strlen($nama) < 2)
$err[] = 'Panjang Nama harus 2 s/d 12 karakter.';
if (!ctype_digit($no_hp) || strlen($no_hp) > 12 || strlen($no_hp) < 8)
$err[] = 'Panjang Nomor HP harus 2 s/d 12 digit.';
elseif (substr($no_hp, 0, 1) != '0')
$err[] = 'Nomor HP harus diawali angka 0';
if (strlen($pesan) > 160 || strlen($pesan) < 2)
$err[] = 'Panjang Pesan harus 2 s/d 160 karakter.';
if (!$kode || !isset($_SESSION['code']) || mb_strlen($kode) < 4 || strtolower($kode) !=
strtolower($_SESSION['code']))
$err[] = 'Kode keamanan tidak benar.';
unset($_SESSION['code']);
if (empty($err)) {
$q = $pdo->prepare("INSERT INTO testimonial (nama, no_hp, pesan, tanggal) VALUES (?, ?, ?, ?)");
$q->execute(array($nama,$no_hp,$pesan,time()));
$_SESSION['testi'] = 1;
header("Location: ".SITE_URL."testimonial.php?page=$page&ok=1#alert");
}
else {
$error = '<div class="alert alert-danger" id="alert"><ol><li>'.implode('</li><li>',$err).'</li></ol></div>';
}
}
$q = $pdo->query("SELECT COUNT(*) FROM testimonial WHERE moderasi = '0'");
$total = $q->fetchColumn();
if ($total && !isset($_GET['page']) && $total > $set['list_per_page']) {
$last_page = ceil($total / $set['list_per_page']);
header("Location: ".SITE_URL."testimonial.php?page=".$last_page);
exit();
}
include ('includes/header.php');
?>
<h3>Testimonial</h3>
<div class="row">
<div class="col-sm-8">
<?php
if ($total) {
echo '<ul class="list-group">';
$q = $pdo->query("SELECT * FROM testimonial WHERE moderasi = '0' ORDER BY tanggal ASC LIMIT $start, {$set['list_per_page']}");
foreach ($q->fetchAll() as $testi) {
echo '<li class="list-group-item"><div class="list-group-item-heading">'.
'<span class="text-muted pull-right"><small>' . format_tanggal($testi->tanggal) .
'</small></span><strong>' . __e($testi->nama) . '</strong> <span class="text-muted">('.substr($testi->no_hp,0,-3).'xxx)</span></div>'.
'<div class="list-group-item-text">' . nl2br(__e($testi->pesan)) . '</div></li>';
}
echo '</ul>';
echo '<div style="margin: 0 auto;text-align:center;">'.pagination(SITE_URL.'testimonial.php?', $start, $total, $set['list_per_page']).'</div>';
}
?>
</div>
<div class="col-sm-4">
<div class="well well-sm">
<h4>Kirimkan Testimonial</h4>
<?php if (isset($error)):?>
<?php echo $error?>
<?php elseif (isset($_GET['ok'])):?>
<div class="alert alert-success" id="alert">Pesan Anda telah dikirm, dan akan ditampilkan setelah disetujui Administrator.</div>
<?php endif?>
<form id="form1" class="" method="post" action="<?php echo SITE_URL?>testimonial.php?page=<?php echo $page?>#alert">
<div class="form-group">
<label for="nama" class="control-label">
Nama
</label>
<input type="text" class="form-control" name="nama" id="nama" maxlength="12" required="required" value="<?php echo __e($nama)?>"<?php echo (isset($_SESSION['testi']) ? ' disabled="disabled"' : '')?>/>
</div>
<div class="form-group">
<label for="no_hp" class="control-label">
Nomor HP
</label>
<input type="text" class="form-control" name="no_hp" id="no_hp" maxlength="12" placeholder="08xxxxxxxxxx" required="required" value="<?php echo __e($no_hp)?>"<?php echo (isset($_SESSION['testi']) ? ' disabled="disabled"' : '')?>/>
</div>
<div class="form-group">
<label for="pesan" class="control-label">
Pesan
</label>
<textarea class="form-control" name="pesan" id="pesan" required="required" maxlength="160" rows="4"<?php echo (isset($_SESSION['testi']) ? ' disabled="disabled"' : '')?>><?php echo __e($pesan)?></textarea>
</div>
<div class="form-group">
<label for="kode" class="control-label">
Kode Keamanan
</label>
<div class="input-group">
<span class="input-group-addon" style="padding: 0;">
<img src="<?php echo SITE_URL?>captcha.php" style="" alt="Loading...."/>
</span>
<input type="text" class="form-control input-lg" name="kode" id="kode" maxlength="5" size="5" required="required"<?php echo (isset($_SESSION['testi']) ? ' disabled="disabled"' : '')?>/>
</div>
</div>
<div class="form-group">
<button type="submit" name="submit" value="1" class="btn btn-primary<?php echo (isset($_SESSION['testi']) ? ' disabled' : '')?>">
Kirim
</button>
</div>
</form>
</div>
</div>
</div>
<?php
include ('includes/footer.php');
?>