-
Notifications
You must be signed in to change notification settings - Fork 0
/
signingUp.php
50 lines (32 loc) · 962 Bytes
/
signingUp.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
<?php
include_once 'db.php';
// prepare and bind
$stmt = $db->prepare("INSERT INTO people (password, username, email) VALUES (SHA1(?), ?, ?)");
$stmt->bind_param("sss", $password, $username, $email);
// set parameters and execute
$password = $_POST['passwordCreate'];
$username = trim($_POST['usernameCreate']," ");
print($username);
print($_POST['usernameCreate']);
$email = $_POST['emailCreate'];
if ($stmt->execute()){
header("location: parentOrChild.php");
} else {
print("error: ".$db->error);
}
$sql = "SELECT id FROM people WHERE username=? AND password=(SHA1(?))";
$stmt = $db->prepare($sql);
if (!$stmt){
print("error: ".$db->error);
}
$stmt->bind_param("ss", $username, $password);
$stmt->execute();
$result = $stmt->get_result();
$row = $result->fetch_assoc(); //row = id array
$id = $row['id'];
print($id);
session_start();
$_SESSION['username'] = $username;
$_SESSION['password'] = $password;
$_SESSION['id'] = $id;
?>