This repository has been archived by the owner on Nov 11, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathcapturedata.php
129 lines (117 loc) · 3.3 KB
/
capturedata.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
<?php error_reporting(E_ALL);
ini_set('display_errors', '1');
include('functions.php');
include("connect.php");
/* This logic moved to update-profile.php and dashboard.php
$paid = 0;
$seeks = 0;
if (isset($_REQUEST['seeksmale']) && $_REQUEST['seeksmale'] == 'on')
$seeks |= 1;
if (isset($_REQUEST['seeksfemale']) && $_REQUEST['seeksfemale'] == 'on')
$seeks |= 2;
if ($_REQUEST['gender'] == 'm')
$gender = 1;
else
$gender = 2;
$nameFrags = explode(" ",$_REQUEST['name']);
$firstname = $nameFrags[0];
$lastname = $nameFrags[1];
$db = db_connect();
$stmt = $db->stmt_init();
if ($stmt->prepare("DELETE FROM `queue` WHERE `token`=?"))
{
$stmt->bind_param('s',$_REQUEST['token']);
$stmt->execute();
}
$id = 'flag';
if ($stmt->prepare("SELECT `id` FROM `profile` WHERE `email`=?"))
{
$stmt->bind_param('s',$_REQUEST['email']);
$stmt->execute();
$stmt->store_result();
$stmt->bind_result($id);
if ($stmt->num_rows > 0)
{
$stmt->fetch();
}
$stmt->free_result();
}
if ($id == 'flag') // New user profile
{
if ($stmt->prepare("INSERT INTO `profile` (`firstname`,`lastname`,`box`,`phone`,`email`,`gender`,`seeks`,`paid`,`bio`,`validated`) VALUES(?,?,?,?,?,?,?,?,?,'true')"))
{
$stmt->bind_param('ssissiiis',$firstname,$lastname,$_REQUEST['box'],$_REQUEST['phone'],$_REQUEST['email'],$gender,$seeks,$paid,$_REQUEST['bio']);
$stmt->execute();
if ($stmt->insert_id < 0){
$stmt->close();
$db->close();
die("Something went wrong");
}
$id = $stmt->insert_id;
}
}else
{
if ($stmt->prepare("UPDATE `profile` SET `firstname`=?,`lastname`=?,`box`=?,`phone`=?,`gender`=?,`seeks`=?,`paid`=?,`bio`=? WHERE `id`=?"))
{
$stmt->bind_param('ssisiiisi',$firstname,$lastname,$_REQUEST['box'],$_REQUEST['phone'],$gender,$seeks,$paid,$_REQUEST['bio'],$id);
$stmt->execute();
}
}
*/
if (!isset($_SESSION))
session_start();
$id = $_SESSION['id'];
// First delete previous answers if any
$q = "DELETE FROM `response` WHERE `profile_id`= " . $_SESSION['id'];
$result = mysql_query($q);
if(!$result)
die(mysql_error());
// insert question answers
foreach($_REQUEST as $key => $value)
{
$pos = strpos($key,'question_');
if($pos === false)
continue;
else
{
$questionFrag = explode('_',$key);
$question = intval($questionFrag[1]);
$answer = intval($value);
$q = "INSERT INTO `response` (`profile_id`,`question_id`,`answer`) VALUES ($id,$question,$answer)";
$result= mysql_query($q);
if(!$result)
die(mysql_error());
}
}
if(isset($_REQUEST['instant']))
{
include("update-profile.php");
header("location: saved.php");
}
else
{
header("location: dashboard.php");
}
/*
if ($stmt->prepare("INSERT INTO `response` (`profile_id`,`question_id`,`answer`) VALUES (?,?,?)"))
{
$stmt->bind_param('iii',$id,$question,$answer);
foreach($_REQUEST as $key => $value)
{
$pos = strpos($key,'question_');
if($pos === false) {
continue;
}
else {
$questionFrag = explode('_',$key);
$question = intval($questionFrag[1]);
$answer = intval($value);
$stmt->execute();
}
}
$stmt->close();
$db->close();
header("Location: saved.php");
}
$db->close(); // Just in case */
?>