-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaddUser.php
35 lines (28 loc) · 1 KB
/
addUser.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
<?php
session_start();
include 'common_functions.php';
$username = $nickname = $email = $password = $password_match = "";
// Receive and sanitize input
if ($_SERVER["REQUEST_METHOD"] == "POST" && !empty($_POST) )
{
$username = test_input($_POST['username']);
$nickname = test_input($_POST['nickname']);
$email = test_input($_POST['email']);
$password = test_input($_POST['password']);
$password_match = test_input($_POST['password_match']);
$date = date('Y-m-d H:i:s'); // set the date as now
if($password === $password_match && isValidEmail($email))
{
$conn = OpenDBconnection();
// encrypt password
$pwd = sha1($password);
// write to db
$sql = "INSERT INTO users (username, nickname, email, password) VALUES ('$username', '$nickname', '$email', '$pwd')";
$result = $conn->query($sql);
CloseDBconnection($conn);
RedirectTo('registration_success.php?nickname='.$nickname);
}
}
else
RedirectTo('form_registration.php');
?>