-
Notifications
You must be signed in to change notification settings - Fork 0
/
new_faq.php
69 lines (66 loc) · 2.01 KB
/
new_faq.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
<?php
if($_SESSION['login_type'] > 2):
{
// header('Location: index.php?page=home');
echo "<script type='text/javascript'>location.href = 'index.php';</script>";
exit(0);
}
endif;
?>
<div class="col-lg-12">
<div class="card">
<div class="card-body">
<form action="" id="manage_faq" enctype="multipart/form-data">
<input type="hidden" name="questionID" value="<?php echo isset($questionID) ? $questionID : '' ?>">
<div class="row">
<div class="col-md-6 border-right">
<div class="form-group">
<label for="" class="control-label">Question</label>
<input type="text" name="question" class="form-control form-control-sm" required value="<?php echo isset($question) ? $question : '' ?>">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label class="control-label">Answer</label>
<input type="text" class="form-control form-control-sm" name="answer" required value="<?php echo isset($answer) ? $answer : '' ?>">
<small id="msg"></small>
</div>
</div>
</div>
<hr>
<div class="col-lg-12 text-right justify-content-center d-flex">
<button class="btn btn-primary mr-2">Save</button>
<button class="btn btn-secondary" type="button" onclick="location.href = 'index.php?page=faqs'">Cancel</button>
</div>
</form>
</div>
</div>
</div>
<script>
$('#manage_faq').submit(function(e){
e.preventDefault()
$('input').removeClass("border-danger")
start_load()
$('#msg').html('')
$.ajax({
url:'ajax.php?action=save_faq',
data: new FormData($(this)[0]),
cache: false,
contentType: false,
processData: false,
method: 'POST',
type: 'POST',
success:function(resp){
if(resp == 1){
alert_toast("Data successfully saved.",'success')
setTimeout(function(){
location.replace('./index.php?page=faqs')
},750)
}else if(resp == 2){
$('#msg').html("<div class='alert alert-danger'>Unexpected error.</div>");
end_load();
}
}
})
})
</script>