-
Notifications
You must be signed in to change notification settings - Fork 0
/
createfamily.php
executable file
·49 lines (43 loc) · 1.36 KB
/
createfamily.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
<?php
//echo $_POST["description"];
//echo $_FILES["fileUpload"]['name'];
//echo $_POST['guardian'];
$file_path = "profile_pic/";
$picture = $file_path.$_FILES['fileUpload']['name'];
move_uploaded_file($_FILES['fileUpload']['tmp_name'], $file_path.$_FILES['fileUpload']['name']);
require_once'config.php';
$con =mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
mysql_select_db(DB_NAME, $con);
$username = $_POST['username'];
$email = $_POST['email'];
$password = $_POST['password'];
$familyname = $_POST['family'];
$invitation = $_POST['invitation'];
if($_POST['guardian']=="false"){
$guardian = 0;
}
else{
$guardian = 1;
}
$query = "INSERT INTO Family(FamilyName,InvitationCode)
VALUES('$familyname', '$invitation')";
$fidquery = "SELECT @@IDENTITY";
mysql_query($query, $con);
$data = mysql_query($fidquery, $con);
$fid = mysql_fetch_array($data)['@@IDENTITY'];
$query = "INSERT INTO User(FId, Username, Email, Password, Picture, Guardian)
VALUES('$fid', '$username', '$email', '$password', '$picture', '$guardian')";
$uidquery = "SELECT @@IDENTITY";
if(mysql_query($query, $con)){
$uiddata = mysql_query($uidquery, $con);
$uid = mysql_fetch_array($uiddata)['@@IDENTITY'];
$resultArray = array();
$resultArray['uid'] = $uid;
$resultArray['fid'] = $fid;
$resultArray['invitation'] = $invitation;
echo json_encode($resultArray);
}
else{
echo "failemail";//email duplicate
}
?>