-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsignup.php
123 lines (107 loc) · 3.61 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
<?php
session_start();
?>
<meta charset="utf-8">
<title>Cloud Music</title>
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<link rel="stylesheet" href="https://code.getmdl.io/1.3.0/material.indigo-pink.min.css">
<link href="mystyle.css" rel="stylesheet" type="text/css"/>
<script defer src="https://code.getmdl.io/1.3.0/material.min.js"></script>
<div class="demo-layout-transparent mdl-layout mdl-js-layout">
<header class="mdl-layout__header mdl-layout__header--transparent">
<div class="mdl-layout__header-row">
<!-- Title -->
<span class="mdl-layout-title">Cloud Music. Inc</span>
<!-- Add spacer, to align navigation to the right -->
<div class="mdl-layout-spacer"></div>
</div>
</header>
<main class="mdl-layout__content">
<div class="mdl-grid">
<div class="mdl-cell mdl-cell--4-col"></div>
<div class="mdl-cell mdl-cell--4-col">
<?php
include "console.php";
$servername = "127.0.0.1";
$username = "root";
$password = "passmysql";
$dbname = "music";
$conn = mysqli_connect($servername, $username, $password, $dbname);
// test connection
if ($conn->connect_error) {
die("connect to mysql,failed: " . $conn->connect_error);
}
$upusername = mysqli_real_escape_string($conn,$_POST["upusername"]);
$upupassword = mysqli_real_escape_string($conn,$_POST["upupassword"]);
$upuname = mysqli_real_escape_string($conn,$_POST["upuname"]);
$empty = ($upusername=="") || ($upupassword=="") || ($upuname=="");
if($empty == True){
$conn->close();
echo "<div class=\"demo-card-event mdl-card mdl-shadow--2dp\">
<div class=\"mdl-card__title mdl-card--expand\">
<h4>
Error, Failed. Empty Inputs are not accepted.
</h4>
</div>
<div class=\"mdl-card__actions mdl-card--border\">
<a href=\"index.html\" class=\"mdl-button mdl-button--colored mdl-js-button mdl-js-ripple-effect\" >
Go back.
</a>
<div class=\"mdl-layout-spacer\"></div>
<i class=\"material-icons\">event</i>
</div>
</div>";
}
else{
$upupassword_hashed = password_hash($upupassword, PASSWORD_DEFAULT);
//console_log($upupassword_hashed);
$signupsql = "CALL signup('" . $upusername . "','". $upupassword_hashed . "','" . $upuname . "');";
$result = $conn->query($signupsql);
$conn->close();
if ($result != True){
echo "<div class=\"demo-card-event mdl-card mdl-shadow--2dp\">
<div class=\"mdl-card__title mdl-card--expand\">
<h4>
Error, Failed. Something wrong with your input and our database.
</h4>
</div>
<div class=\"mdl-card__actions mdl-card--border\">
<a href=\"index.html\" class=\"mdl-button mdl-button--colored mdl-js-button mdl-js-ripple-effect\" >
Go back.
</a>
<div class=\"mdl-layout-spacer\"></div>
<i class=\"material-icons\">event</i>
</div>
</div>";
}else{
echo "<div class=\"demo-card-success mdl-card mdl-shadow--2dp\">
<div class=\"mdl-card__title mdl-card--expand\">
<h4>
You signed up successfully!
</h4>
</div>
<div class=\"mdl-card__actions mdl-card--border\">
<a href=\"index.html\" class=\"mdl-button mdl-button--colored mdl-js-button mdl-js-ripple-effect\" >
Go back.
</a>
<div class=\"mdl-layout-spacer\"></div>
<i class=\"material-icons\">event</i>
</div>
</div>";
}
}
?>
</div>
<div class="mdl-cell mdl-cell--4-col"></div>
</div>
</main>
<footer class="mdl-mini-footer">
<div class="mdl-mini-footer--left-section">
<ul class="mdl-mini-footer--link-list">
<li><a href="#">Help</a></li>
<li><a href="#">Privacy and Terms</a></li>
<li><a href="#">User Agreement</a></li>
</ul>
</div>
</footer>
</div>