-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcreate_contact.php
97 lines (94 loc) · 3.53 KB
/
create_contact.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
<?php
/**
* File create_contact.php
*
* PHP version 5.3+
* A view to get user interface of create contact form
*
* @author Dzung Nguyen <[email protected]>
* @copyright 2013-2015 evolpas
* @license http://www.evolpas.com license
* @version XXX
* @link http://www.evolpas.com
* @category root
*/
require_once 'autoloader.php';
$contactCtrl = new Controllers\ContactController();
$cities = $contactCtrl->getCities();
if (!empty($_POST)) {
$contactCtrl->data = $_POST;
$insert = $contactCtrl->createContactAction();
if ($insert !== false) {
header('Location: index.php');
} else {
$error_log = 'Error: Cannot insert data!';
}
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Address book :: Create new</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width,initial-scale=1">
<link rel="stylesheet" href="assets/css/main.css">
</head>
<body>
<!-- container -->
<div id="container">
<!-- main -->
<div id="main">
<div class="center">
<h2 class="title">Create contact</h2>
<div class="nav-menu">
<a href="index.php">Contacts list</a>
</div>
<div id="form">
<?php if (isset($error_log)) { ?>
<span class='error'><?php echo $error_log; ?></span>
<?php } ?>
<form id="fmCreateContact" method="POST" action="create_contact.php">
<label for="name">Name</label>
<input type="text" id="name" name="name" class="text" required>
<label for="first_name">First name</label>
<input type="text" id="first_name" name="first_name" class="text" required>
<label for="street">Street</label>
<input type="text" id="street" name="street" class="text" required>
<label for="zip_code">Zip-code</label>
<input type="text" id="zip_code" name="zip_code" class="text" required>
<label for="city">City</label>
<select id="id_city" name="id_city" class="select" required>
<option value="">--Select City--</option>
<?php foreach ($cities as $city): ?>
<option value="<?php echo $city['id'] ?>"><?php echo $city['city_name'] ?></option>
<?php endforeach; ?>
</select> <input type="button" onclick="javascript: dialogModal()" value="Add" style="height: 30px" />
<input type="submit" value="Save" class="submit" />
<input type="reset" value="Cancel" class="submit" />
</form>
</div>
</div>
</div>
</div>
<!-- Dialog model to add city -->
<div id="overlay">
<div id="content" class="content-dialog">
<div id="toolbar" class="toolbar-dialog"><p>Add City</p><a href="javascript:void(0)" onclick="javascript: dialogModal()">[X]</a></div>
<div>
<div class="message"><span id="message"></span></div>
<form id="fmAddCity" method="POST" action="add_city.php">
<label for="city_name">City name</label>
<input type="text" id="city_name" name="city_name" class="text" required>
<label for="description">Description</label>
<input type="text" id="description" name="description" class="text">
<input type="submit" onclick="addCity(); return false;" value="Save" class="submit">
<input type="reset" onclick="javascript:dialogModal();" value="Cancel" class="submit">
</form>
</div>
</div>
</div>
<!-- script -->
<script src="assets/js/main.js"></script>
</body>
</html>