-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathreg-ind-controller.php
28 lines (24 loc) · 1.14 KB
/
reg-ind-controller.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
<?php
if ($_POST['password'] != $_POST['cpassword']){
echo "<script type='text/javascript'>alert('Password entries do not match.')</script>";
}
require "db.conf";
$_SESSION['email'] = $_POST['email'];
if ($link = mysqli_connect($dbhost, $dbuser, $dbpass, $dbname)){
$sql = "INSERT INTO Profile (email, hashpass) VALUES (?,?)";
if ($stmt = mysqli_prepare($link, $sql)) {
$email = $_POST['email'];
$pass = $_POST['password'];
$cpass = $_POST['cpassword'];
$hpass = password_hash($pass, PASSWORD_BCRYPT);
mysqli_stmt_bind_param($stmt, "ss", $email, $hpass) or die("bind param");
if ($pass == $cpass){
if(mysqli_stmt_execute($stmt)) {
header("Location: index.php?id=reg-ind2");
} else { echo "<script type='text/javascript'>alert('This email already has a LinkedIn account associated with it.')</script>"; }
}
mysqli_stmt_close($stmt);
mysqli_close($link);
} else { echo "<script type='text/javascript'>alert('Prepared statement failed.')</script>"; }
} else { echo "<script type='text/javascript'>alert('Unable to establish a MySQL connection.')</script>"; }
?>