-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathregistration.php
163 lines (122 loc) · 4.28 KB
/
registration.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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
<?php
/**
* Created by IntelliJ IDEA.
* User: micha
* Date: 2/25/2018
* Time: 3:31 AM
*/
session_start();
require 'database.php';
$username = 'michael';
$password = 'pass';
$crypt = password_hash($password, PASSWORD_DEFAULT);
$stmt = $mysqli->prepare("SELECT COUNT(*) FROM users WHERE username=?");
if(!$stmt){
printf("Query Prep Failed: %s\n", $mysqli->error);
exit;
}
$stmt->bind_param('s', $username);
$stmt->execute();
$stmt->bind_result($cnt);
$stmt->fetch();
$stmt->close();
$alreadyRegistered = false;
if ($cnt == 1){
$alreadyRegistered = true;
} else {
$_SESSION['username'] = $username;
$stmt = $mysqli->prepare("INSERT INTO users (username, password) VALUES (?,?)");
if(!$stmt){
printf("Query Prep Failed: %s\n", $mysqli->error);
exit;
}
$stmt->bind_param('ss', $username, $crypt);
$stmt->execute();
$stmt->fetch();
$stmt->close();
}
$recipe_name = 'Chocolate Chip Cookies';
$recipe_ingredients = '5 oz Butter
2/3 cup Brown Sugar
1/2 cup Granulated Sugar
1 ea Eggs
1 tsp Vanilla Extract
1 cup Cake Flour
3/4 cup Bread Flour
2/3 tsp Baking Soda
3/4 tsp Baking Powder
3/4 tsp Salt
8 oz Semi-sweet Chocolate Chips';
$recipe_steps = '1. Cream the Butter and Sugars
2. Add Vanilla and Eggs - beat until incorporated
3. Add Flour, Baking Powder, Baking Soda, and Salt
4. When dough comes together, fold in chocolate chips - do not over-mix!
5. Using room-temperature dough, scoop into balls and place on a lined sheet tray, arranging them in a staggered pattern
6. Bake 350 for 10 minutes - when you remove them from the oven, drop the tray on the floor to "flatten" the cookies
7. When cool, store/serve appropriately';
$stmt = $mysqli->prepare("INSERT INTO recipes (username, recipe_name, recipe_ingredients, recipe_steps) VALUES (?,?,?,?)");
if(!$stmt){
printf("Query Prep Failed: %s\n", $mysqli->error);
exit;
}
$stmt->bind_param('ssss', $username, $recipe_name, $recipe_ingredients, $recipe_steps);
$stmt->execute();
$stmt->close();
$recipe_name = 'Custom Recipe #1';
$recipe_ingredients = 'Custom Recipe Ingredients';
$recipe_steps = 'Custom Recipe Steps';
$stmt = $mysqli->prepare("INSERT INTO recipes (username, recipe_name, recipe_ingredients, recipe_steps) VALUES (?,?,?,?)");
if(!$stmt){
printf("Query Prep Failed: %s\n", $mysqli->error);
exit;
}
$stmt->bind_param('ssss', $username, $recipe_name, $recipe_ingredients, $recipe_steps);
$stmt->execute();
$stmt->close();
$recipe_name = 'Custom Recipe #2';
$recipe_ingredients = 'Custom Recipe Ingredients';
$recipe_steps = 'Custom Recipe Steps';
$stmt = $mysqli->prepare("INSERT INTO recipes (username, recipe_name, recipe_ingredients, recipe_steps) VALUES (?,?,?,?)");
if(!$stmt){
printf("Query Prep Failed: %s\n", $mysqli->error);
exit;
}
$stmt->bind_param('ssss', $username, $recipe_name, $recipe_ingredients, $recipe_steps);
$stmt->execute();
$stmt->close();
$recipe_name = 'Custom Recipe #3';
$recipe_steps = 'Custom Recipe';
$recipe_ing = 'Custom Recipe';
$stmt = $mysqli->prepare("INSERT INTO recipes (username, recipe_name, recipe_ingredients, recipe_steps) VALUES (?,?,?,?)");
if(!$stmt){
printf("Query Prep Failed: %s\n", $mysqli->error);
exit;
}
$stmt->bind_param('ssss', $username, $recipe_name, $recipe_ingredients, $recipe_steps);
$stmt->execute();
$stmt->close();
$recipe_name = 'Custom Recipe #4';
$recipe_ingredients = 'Custom Recipe Ingredients';
$recipe_steps = 'Custom Recipe Steps';
$stmt = $mysqli->prepare("INSERT INTO recipes (username, recipe_name, recipe_ingredients, recipe_steps) VALUES (?,?,?,?)");
if(!$stmt){
printf("Query Prep Failed: %s\n", $mysqli->error);
exit;
}
$stmt->bind_param('ssss', $username, $recipe_name, $recipe_ingredients, $recipe_steps);
$stmt->execute();
$stmt->close();
$recipe_name = 'Custom Recipe #5';
$recipe_ingredients = 'Custom Recipe Ingredients';
$recipe_steps = 'Custom Recipe Steps';
$stmt = $mysqli->prepare("INSERT INTO recipes (username, recipe_name, recipe_ingredients, recipe_steps) VALUES (?,?,?,?)");
if(!$stmt){
printf("Query Prep Failed: %s\n", $mysqli->error);
exit;
}
$stmt->bind_param('ssss', $username, $recipe_name, $recipe_ingredients, $recipe_steps);
$stmt->execute();
$stmt->close();
$arr = array("alreadyRegistered" => $alreadyRegistered, "crypt" => $crypt);
echo json_encode($arr);
?>