-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathjoin.php
executable file
·113 lines (91 loc) · 3.03 KB
/
join.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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
<?php
include 'includes.php';
session_start();
if(isset($_SESSION['isAdmin']) && $_SESSION['isAdmin']) {
header("Location: view.php");
} elseif(isset($_SESSION['isClient']) && $_SESSION['isClient']) {
//logged in as a client => go back to public_view
} else {
//otherwise this page is for not logged in
}
//otherwise this page is for not logged in
if(isset($_POST['submit']))
{
$blog_name = $_POST['blog_name'];
$username = $_POST['username'];
$password = sha1($_POST['password']);
$email = $_POST['email'];
if(!empty($blog_name) && !empty($username) && !empty($_POST['password']) && !empty($email)) {
Connect();
mysql_select_db('blog');
$sql = "SELECT * FROM people WHERE username = '$username'";
$result = mysql_query($sql);
if ($person = mysql_fetch_assoc($result)) {
$error_msg = "Username already in use. Please try another username.";
$success = false;
} else {
$sql = "INSERT INTO people (blog_name, username, password, email) VALUES ('$blog_name', '$username', '$password', '$email')";
mysql_query($sql);
Disconnect();
/*
$subject = 'Welcome to SamBlogger!';
$body = "Dear " . $username . ",\n\n On behalf of Simple SamSoft Solutions, I'd like to thank you for joining SamBlogger!";
$header = 'From: ' . "Marina Samuel" . "\r\n" . 'Reply-To: ' . "[email protected]";
mail($email, $subject, $body, $header);
*/
$success = true;
}
}
else {
$error_msg = "Please fill in all fields before continuing";
$success = false;
}
}
?>
<html>
<head>
<title>Join SamBlogger | Marina Samuel</title>
<link rel="stylesheet" type="text/css" href="web.css" />
</head>
<body>
<div id="container">
<div id="main">
<div id="topNavigator">
<ul>
<li><a href='index.php'>Home</a></li>
<li><a href='login.php'>Login</a></li>
</ul>
</div>
<hr color='grey'>
</div>
<div id="center">
<h2>Join SamBlogger Free!</h2>
<?php
if(isset($success) && !$success) {
echo "<span class='dynamic_text'><p id='warning'>" . $error_msg . "</p></span>";
} elseif(isset($success) && $success) {
echo "<span class='dynamic_text'><p>Thank you! You are now an official member of SamBlogger!</p></span>";
}
?>
<form method="post" action="">
<div id="form-format">
<label for="username">Blog Name: </label>
<input type="text" name="blog_name"/>
<br/>
<label for="username">Username: </label>
<input type="text" name="username"/>
<br/>
<label for="password">Password: </label>
<input type="password" name="password"/>
<br/>
<label for="email">Email: </label>
<input type="text" name="email"/>
<br/>
</div>
<input type="submit" name="submit" value="Join Now!"/>
</form>
</div>
<div class="clearfix"></div>
</div>
</body>
</html>