-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaddcountry.php
68 lines (60 loc) · 1.81 KB
/
addcountry.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
<?php
require_once 'require/util.php'; //utility functions
require_once 'require/htmllib.php'; //HTML functions
require_once 'require/sublib.php'; //subdivision database functions
require_once 'require/config.php'; //server info
error_reporting(E_ALL); ///YES! YES! YES!
begin_session();
//begin page generation
print_htmlhead(LANG_ADDCOUNTRY,0);
//Connect to Server
$server = bank_server_connect();
//the main event.
if ($_SESSION['authorized'] AND (($_SESSION['username'] == DB_ADMIN_NAME) OR ($_SESSION['status'] == 'Admin'))) //check for login and make sure they are the admin
{
if (!isset($_POST['submitted'])) //was the form submitted?
{
print_form($server);
}
else if (isset($_POST['submitted'])) //The form was submitted.
{
$subdivision = clean_input($_POST['subdivision']);
$country = clean_input($_POST['country']);
if (!ctype_alnum(preg_replace('/[[:space:]]/', '', $subdivision)))
{
print (LANG_ADDCOUNTRY_1."<br />");
}
else if (!ctype_alnum(preg_replace('/[[:space:]]/', '', $country)))
{
print (LANG_ADDCOUNTRY_2."<br />");
}
else if (!add_subdivision($subdivision, $country, $server))
{
print ($subdivision.", ".$country.LANG_ADDCOUNTRY_3.".<br />");
}
else
{
bank_error(LANG_ADDCOUNTRY_4."<br />");
}
}
}
else
{
print(LANG_MUSTBEADMIN."<br />");
}
print_htmlfoot();
//functions
function print_form($server)
//prints the form
{
print ('<form action="addcountry.php" method="post">');
print (LANG_ADDCOUNTRY_5.":<br />");
print ('<input type="text" size="20" value="" name="country"><br />');
print ('<br />');
print (LANG_ADDCOUNTRY_6.":<br />");
print ('<input type="text" size="20" value="Proper" name="subdivision"><br />');
print ('<input type="hidden" name="submitted" value="true" />');
print ("<input type='submit' value='".LANG_ADDCOUNTRY_ADD."' />");
print ('</form>');
}
?>