-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdosignup.php
More file actions
92 lines (74 loc) · 2.34 KB
/
dosignup.php
File metadata and controls
92 lines (74 loc) · 2.34 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
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
<?php
if(isset($_POST['signup'])) {
define('MyConst', TRUE);
}
if(!defined('MyConst')) {
echo '<script language="javascript">';
echo 'alert("Access Denied");';
echo '</script>';
header("Refresh: 1; url=index.php");
}
else {
if(!empty($_POST['name']) && !empty($_POST['email']) && !empty($_POST['password'])) {
$name = htmlentities($_POST['name']);
$email = htmlentities($_POST['email']);
$pass = md5(htmlentities($_POST['password']));
}
else {
echo '<script language="javascript">';
echo 'alert("Enter All the Details first !");';
echo '</script>';
header("Location:index.php");
}
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "pdologin";
$tbname = "userDetails";
try {
$conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$stmt = $conn->prepare('SELECT * FROM userDetails WHERE email = :email');
$stmt->execute(['email' => $email]);
$user = $stmt->fetch(PDO::FETCH_ASSOC);
$stmt1 = $conn->prepare('SELECT * FROM userDetails WHERE name = :name');
$stmt1->execute(['name' => $name]);
$user1 = $stmt1->fetch(PDO::FETCH_ASSOC);
if($user != NULL) {
echo '<script language="javascript">';
echo 'alert("Email Already Registered ");';
echo '</script>';
header("Refresh: 1; url=index.php");
}
elseif($user1 != NULL) {
echo '<script language="javascript">';
echo 'alert("Username Already Exists !");';
echo '</script>';
header("Refresh: 1; url=index.php");
}
else {
$sql = $conn->prepare("INSERT INTO $tbname (name,email,password) VALUES (:name,:email,:password)");
$do = $sql->execute(['name' => $name, 'email' => $email, 'password' => $pass]);
if($do) {
echo '<script language="javascript">';
echo 'alert("Signed up Successfully !");';
echo '</script>';
header("Refresh: 1; url=login.php");
}
else {
echo '<script language="javascript">';
echo 'alert("Looks like there is some Error !");';
echo '</script>';
header("Refresh: 1; url=index.php");
}
}
}
catch(PDOException $e) {
echo '<script language="javascript">';
echo '$sql . "<br>" . $e->getMessage();';
echo '</script>';
header("Refresh: 1; url=index.php");
}
$conn = NULL;
}
?>