-
-
Notifications
You must be signed in to change notification settings - Fork 26
/
signup.php
129 lines (111 loc) · 5.53 KB
/
signup.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
session_start();
if( isset($_SESSION['user'])){
header("Location: profile.php");
}
include('connect.php');
?>
<!DOCTYPE html>
<html>
<head>
<title> Interrogate </title>
<link type="text/css" rel="stylesheet" href="css/style.css">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link type="text/css" rel="stylesheet" href="css/material.css">
<link type="text/css" rel="stylesheet" href="fonts/font.css">
<link rel="icon" href="images/icon1.png" >
</head>
<body id="_6">
<!-- navigation bar -->
<a href="index.php">
<div id="log">
<div id="i">i</div><div id="cir">i</div><div id="ntro">nterrogate</div>
</div>
</a>
<ul id="nav-bar">
<a href="index.php"><li>Home</li></a>
<a href="categories.php"><li>Categories</li></a>
<a href="contacts.php"><li>Contact</li></a>
<a href="ask.php"><li>Ask Question</li></a>
<?php
if(! isset($_SESSION['user'])){
?>
<a href="login.php"><li>Log In</li></a>
<a href="signup.php"><li id="home">Sign Up</li></a>
<?php
}
else{
?>
<a href="profile.php"><li>Hi, <?php echo $_SESSION["user"]; ?></li></a>
<a href="logout.php"><li>Log Out</li></a>
<?php
}
?>
</ul>
<!-- content -->
<div id="content">
<div id="sf">
<center>
<div class="heading">
<h1 class="logo"><div id="i">i</div><div id="cir">i</div><div id="ntro">nterrogate</div></h1>
<p id="tag-line">where questions are themselves the answers</p>
</div>
<form action="<?php echo htmlspecialchars( $_SERVER["PHP_SELF"] ); ?>" method="post" enctype="multipart/form-data">
<input name="username" id="user" type="text" title="This will be your parmanent Id." placeholder="Create a Unique Username" required>
<input name="password" id="key" type="password" title="Password must contain at least 8 characters including alphabets,numbers, and symbols." placeholder="Create a Strong Password" required>
<i class="material-icons" id="lock">lock</i>
<i class="material-icons" id="person">person</i>
<input name="name" id="name" type="text" title="Although, you will be called by your name only" placeholder="Enter your Full Name" required>
<input name="email" id="mailbox" type="email" title="Your Email id is in safe hands." placeholder="Enter your Email Id" required>
<i class="material-icons" id="email">mail</i>
<i class="material-icons" id="iden">perm_identity</i>
<div id="button-block">
<center>
<div class="buttons"><input name="submit" type="submit" value="Create An Account" class="up-in"></div>
<div class="buttons" id="new"><input type="button" value="Already a member : Log In" class="up-in" id="tolog"></div>
</center>
</div>
</form>
</center>
</div>
<div id="ta">
<h1>Thank You For Registering With Us.</h1>
</div>
</div>
<?php
if( isset( $_POST["submit"] ) )
{
function valid($data){
$data=trim(stripslashes(htmlspecialchars($data)));
return $data;
}
$username = valid( $_POST["username"] );
$password = valid( $_POST["password"] );
$password = password_hash($password, PASSWORD_DEFAULT);
$name = valid( $_POST["name"] );
$email = valid( $_POST["email"] );
$query = "INSERT INTO users values( NULL, '$username', '$password', '$name', '$email', CURRENT_TIMESTAMP )";
if(mysqli_error($conn)){
echo "<script>window.alert('Something Goes Wrong. Try Again');</script>";
}
// echo $query;
else if( mysqli_query( $conn, $query) ){
echo "<style>#sf{display: none;} #ta{display:block;}</style>";
}
else{
// echo mysqli_error($conn);
echo "<script>window.alert('Username Already Exist !! Try Again');</script>";
}
mysqli_close($conn);
}
?>
<!-- Footer -->
<div id="footer" style="padding:20px;">
© 2017 • Interrogate Inc.
</div>
<!-- Sripts -->
<script src="https://code.jquery.com/jquery-3.2.1.min.js" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" crossorigin="anonymous"></script>
<script>window.jQuery || document.write('<script type="text/javascript" src="js/jquery-3.2.1.min.js"><\/script>')</script>
<script type="text/javascript" src="js/script.js"></script>
</body>
</html>