-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathregProcess.php
More file actions
66 lines (63 loc) · 2.66 KB
/
regProcess.php
File metadata and controls
66 lines (63 loc) · 2.66 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
56
57
58
59
60
61
62
63
64
65
66
<?php
//List of variable firstName, lastName, gender, userEmail,phoneNumber, userPass1, userPass2, profilePic, termsAgreement
if($_SERVER['REQUEST_METHOD'] == 'POST'){
if(
isset($_POST['firstName'])
&& isset($_POST['lastName'])
&& isset($_POST['gender'])
&& isset($_POST['userEmail'])
&& isset($_POST['phoneNumber'])
&& isset($_POST['userPass1'])
&& !empty($_POST['firstName'])
&& !empty($_POST['lastName'])
&& !empty($_POST['gender'])
&& !empty($_POST['userEmail'])
&& !empty($_POST['phoneNumber'])
&& !empty($_POST['userPass1'])
){
$firstName=$_POST['firstName'];
$lastName=$_POST['lastName'];
$gender=$_POST['gender'];
$email=$_POST['userEmail'];
$phone=$_POST['phoneNumber'];
$pass=$_POST['userPass1'];
try{
$conn=new PDO('mysql:host=localhost:3306;dbname=dreamabroad;',"root","");
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$enc_password=md5($pass); //Password encryption
$mysql_query_reg="INSERT INTO userprofile (firstName,lastName,email,password,gender,phoneNumber)
VALUES ('$firstName','$lastName','$email','$enc_password','$gender','$phone')";
$conn->exec($mysql_query_reg);
//if the insertion success , forward to login page
$id_serach_Query="SELECT * from userprofile WHERE email='$email' && password='$enc_password'";
$returnobj=$conn->query($id_serach_Query);
$temp = $returnobj->fetch(); //Fetching a single row then signle column, single value
//$fName = $temp['firstName'];
$userID = $temp['userID'];
$conn->exec("INSERT INTO address (userProfile_userID) VALUES ($userID);");
$conn->exec("INSERT INTO education (userProfile_userID) VALUES ($userID);"); //joining with these two table for further search
?>
<script>location.assign("login.php");</script>
<?php
}
catch(PDOException $ex){
//if database connection issue then forward to registration page
?>
<script>location.assign("reg.php");</script>
<?php
}
}
else{
//if fields aren't set and empty forward to register
?>
<script>location.assign("reg.php");</script>
<?php
}
}
else{
//for other method we'll forward user to the register page
?>
<script>location.assign("reg.php");</script>
<?php
}
?>