-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathblog_regUserToDB.php
48 lines (31 loc) · 1.12 KB
/
blog_regUserToDB.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
<?PHP
//skickar nya användare till databasen och kollar om det är korrekt.
//ini_set("display_errors", "on");
//error_reporting(-1);
require_once("blog_db.php");
$db = new DB();
$username = $_REQUEST["username"];
//echo($username);
$username = utf8_decode($username);
$username = strtolower($username);
$username = utf8_encode($username);
$eMail = $_REQUEST["eMail"];
$password = $_REQUEST["password"];
$SQL = "select * from user where alias='$username' or eMail='$eMail'";
//echo($SQL);
$matrix = $db->getData($SQL);
if(count($matrix)==0) {
$SQL = "insert into user(eMail, alias, password, admin) values(?, ?, ?, 0)";
$dbCon= $db->getCon();
$statement = $dbCon->prepare($SQL);
if($statement == false) {
echo("Something went wrong!");
} else {
$statement->bind_param("sss", $eMail, $username, $password);
$statement->execute();
echo(1);
}
} else {
echo("This username/email is in use");
}
?>