-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
75 lines (70 loc) · 2.21 KB
/
index.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
<?php
header("Content-Type: text/html; charset=utf-8");
require_once "includes.php";
$errorMsg = "";
$successMsg = "";
$captchaHtml = $areYouHuman -> getPublisherHTML();
if ($_POST['submit']) {
if (Post_Controller::validate($_POST["name_input"]) && Post_Controller::validate($_POST["email_input"]) && Post_Controller::validate($_POST["number_input"])) {
//captcha validation
//Captcha_Controller::validate($areYouHuman);
if (Email_Controller::validate($_POST['email_input'])) {
$sql = "INSERT INTO students(name, email, faculty_number) VALUES (? , ? , ?)";
try {
$database -> exec($sql, array($_POST["name_input"], $_POST["email_input"], $_POST["number_input"]));
$successMsg = "Enrolled. Check your email!";
Email_Controller::emailEnrollmentInformation($_POST["email_input"]);
} catch (Exception $e) {
$errorMsg = "Existing student";
}
} else {
$errorMsg = "Incorrect email";
}
} else {
$errorMsg = "Please fill all the inputs.";
}
}
?>
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="styles/main.css" />
<title> Web Programming with PHP 2012 Enrolling </title>
</head>
<body>
<div id="container">
<img class="logo" src="images/php_logo.png" height="67px" weight="132px"/>
<div id="form-title">Web Programming with PHP 2012</div>
<form id ="loginform" action="" method="post">
<h4><?php echo $errorMsg;?></h4>
<h4><?php echo $successMsg;?></h4>
<table>
<tr>
<td><label for="name_input">Name:</label></td>
<td>
<input type="text" id="name_input" name="name_input" placeholder="Your name" class="input"/>
</td>
</tr>
<tr>
<td><label for="email_input">Email:</label></td>
<td>
<input type="email" id="email_input" class="input" name="email_input" placeholder="Your email"/>
</td>
</tr>
<tr>
<td><label for="number_input">Faculty Number:</label></td>
<td>
<input type="text" id="number_input" class="input" name="number_input" placeholder="Your faculty number"/>
</td>
</tr>
<tr>
<td></td>
<td>
<input type="submit" class="submit" name="submit" value="Submit" />
</td>
</tr>
</table>
</form>
</div>
</body>
</html>