-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathwhichform.php
More file actions
55 lines (40 loc) · 1.26 KB
/
whichform.php
File metadata and controls
55 lines (40 loc) · 1.26 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
<?php
if(!isset($_SESSION))
{
session_start();
}
require __DIR__.'/vendor/autoload.php';
// This assumes that you have placed the Firebase credentials in the same directory
// as this PHP file.
use Kreait\Firebase\Factory;
use Kreait\Firebase\ServiceAccount;
$serviceAccount = ServiceAccount::fromJsonFile(__DIR__.'/yss-project-69ba2-firebase-adminsdk-qpgd1-772443326e.json');
$firebase = (new Factory)
->withServiceAccount($serviceAccount)
->create();
$database = $firebase->getDatabase();
$reference = $database->getReference('/users')->getValue();
$redirectpagename =$_POST["user_type"];
$_SESSION["newuserinfo"] = $_POST;
$year = substr($_SESSION["newuserinfo"]["age"],0,4);
$dob = $_SESSION["newuserinfo"]["age"];
$age = date("Y") - $year;
$actualEmail = $_SESSION["newuserinfo"]["email"];
$emailwithcomma = str_replace(".",",",$actualEmail);
function alert($msg) {
echo "<script type='text/javascript'>alert('$msg');</script>";
}
if($reference[$emailwithcomma]){
// print_r($reference[$emailwithcomma]);
// header("Location:MYcreateaccount.php");
alert("This email already exists. Please try again.");
include "MYcreateaccount.php";
exit;
}
if($age < 18) {
header("Location:MYcreateaccount.php");
}
else{
header("Location:$redirectpagename");
}
?>