-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSignUp.php
More file actions
67 lines (56 loc) · 2.12 KB
/
SignUp.php
File metadata and controls
67 lines (56 loc) · 2.12 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
<?php require_once('Connection.php'); ?>
<?php require_once("Functions.php"); ?>
<?php include("Header.php"); ?>
<?php
$message = "";
$Login = false;
if (isset($_POST['submit'])) { // Form has been submitted.
// form data
$password = trim(mysql_prep($_POST['password']));
$passwordConfirm = trim(mysql_prep($_POST['passwordConfirm']));
$mail = trim(mysql_prep($_POST['mail']));
$salt = generate_salt();
$hashed_password = hash('sha512', $password . $salt);
if(!empty($mail)) {
if ($password == $passwordConfirm) {
$confirm_link = generate_salt(64);
$mysql_query = "INSERT INTO user
(mail, password, salt, ConfirmLink)
VALUES ('" . $mail . "',
'" . $hashed_password . "', '" . $salt . "', '" . $confirm_link . "')";
$result = mysql_query($mysql_query, $connection);
if($result) {
// Bruger lavet
send_mail($mail, "Confirm JBID account", "Confirm at link below \n http://www.319.dk/JBID/Confirm.php?mail=" . $mail . "&key=" . $confirm_link);
$Login = true;
echo "<h1>Account successfully created check your mail for at confirmation mail</h1>";
} else {
// Fejl med databasen detaljer kan ses ved brug af "mysql_error()"
$message = "E-mail already exists";
}
} else {
//Koder ikke ens
$message = "The passwords do not match";
}
} else {
// mail ikke god nok
$message = "E-mail to short";
}
}
if (!$Login) {
echo '<h1>Create JBiD</h1>
<h3>User creation - Got here by accident? Go to <a href="index.php">login</a></h3>
<form id="createUser" method="post">
<p id="error">' . $message . '</p>
<p>Email</p>
<input id="mail" type="email" required autofocus name="mail">
<p>Password</p>
<input id="password1" type="password" required name="password">
<p>Confirm password</p>
<input id="password2" type="password" required name="passwordConfirm">
<p id="matches"> </p>
<input id="createButton" type="submit" value="Create account" name="submit">
</form>';
}
?>
<?php include("Footer.php"); ?>