-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreateAdmin.php
More file actions
104 lines (87 loc) · 2.65 KB
/
createAdmin.php
File metadata and controls
104 lines (87 loc) · 2.65 KB
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
<?php
require 'config.php';
$first_Name='';
$last_Name='';
$address='';
$telephone='';
$year='';
$month='';
$day='';
$date_of_birth='';
$email;
$type_of_farmer='';
$farm_size='';
$username='';
$password='';
$security1='';
$security2;
$answer1;
$answer2;
$firstErr='';
$localhost=DB_HOST;
$name=DB_DATABASE;
$errors=array();
if($_SERVER['REQUEST_METHOD']=="POST"){
try{
$con=new PDO( "mysql:host=$localhost;dbname=$name",DB_USER,DB_PASSWORD);
$con->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$con->beginTransaction();
$sth=$con->prepare("INSERT INTO admin(adminid,firstname,lastname,email,phone,password)VALUES(:ai,:fn,:ln,:em,:tel,:pass)");
//bind values to the actual $iables,nb the values can be anything we just bind them to the $iables, so whatever we put in the $iables that is what the symbols in the values will be so instead of fn we could easily have r
$sth->bindParam(':ai',$_POST['adminid']);
$sth->bindParam(':fn',$_POST['firstname']);
$sth->bindParam(':ln',$_POST['lastname']);
$sth->bindParam(':em',$_POST['email']);
$sth->bindParam(':tel',$_POST['phone']);
$sth->bindParam(':pass',crypt($_POST['password'],CRYPT_BLOWFISH));
$sth->execute();
$con->commit();
}
catch(PDOException $e){
$con->rollBack();
}
$con=null;
exit();
}
?>
<html>
<head>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="scripts/bootstrap.min.css">
<!-- jQuery library -->
<script src="scripts/jquery.min.js"></script>
<!-- Latest compiled JavaScript -->
<script src="scripts/bootstrap.min.js"></script>
</head>
<body>
<div id="regis" class="container" >
<form role="form" action="<?php echo $_SERVER['PHP_SELF'];?>" method='post'>
<div class="form-group">
<label for="loanid">Adminid:</label>
<input type="text" class="form-control" id="adminid" name="adminid">
</div>
<div class="form-group">
<label for="firstname">First Name:</label>
<input type="text" class="form-control" id="firstname" name="firstname">
</div>
<div class="form-group">
<label for="lastname">Last Name:</label>
<input type="text" class="form-control" id="lastname" name="lastname">
</div>
<div class="form-group">
<label for="email">Email address:</label>
<input type="email" class="form-control" id="email" name="email">
</div>
<div class="form-group">
<label for="phone">Phone:</label>
<input type="text" class="form-control" id="phone" name="phone">
</div>
<div class="form-group">
<label for="phone">Password:</label>
<input type="password" class="form-control" id="password" name="password">
</div>
<button type="submit" class="btn btn-default">Submit</button>
</form>
</div>
</body>
</html>