mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-07 12:24:58 +10:00
64 lines
1.5 KiB
PHP
64 lines
1.5 KiB
PHP
<?php
|
|
|
|
$name=$_REQUEST["username"];
|
|
$pwd=$_REQUEST["password"];
|
|
$email=$_REQUEST["email"];
|
|
$website=$_REQUEST["website"];
|
|
$website=$_REQUEST["bio"];
|
|
|
|
if (!$name) {
|
|
echo "{\"string\":Username not provided.}";
|
|
exit;
|
|
}
|
|
if (!$pwd) {
|
|
echo "{\"string\":Password not provided.}";
|
|
exit;
|
|
}
|
|
if (strlen($pwd) < 6) {
|
|
echo "{\"string\":Password must be at least 6 characters long.}";
|
|
exit;
|
|
}
|
|
if (!$email) {
|
|
echo "{\"string\":E-mail not provided.}";
|
|
exit;
|
|
}
|
|
$pwd = hash("ripemd160", $pwd);
|
|
|
|
// Load help class
|
|
require_once("properties.php");
|
|
|
|
// Load properties
|
|
$dbProperties = new Properties();
|
|
$propertiesFile = fopen("db.properties", "rb");
|
|
$dbProperties->load($propertiesFile);
|
|
|
|
// Connect to the DB
|
|
$username=$dbProperties->getProperty("user");
|
|
$password=$dbProperties->getProperty("pass");
|
|
$database=$dbProperties->getProperty("db");
|
|
$mysqli = new mysqli(localhost,$username,$password,$database);
|
|
|
|
// Run the query
|
|
$sql= "SELECT name FROM diylc_user WHERE LOWER(name) = LOWER('".$name."')";
|
|
|
|
if (!$result = $mysqli->query($sql)) {
|
|
echo "{\"string\":Error}";
|
|
exit;
|
|
}
|
|
|
|
$num = $num = $result->num_rows;
|
|
if ($num === 0) {
|
|
$sql= "INSERT INTO diylc_user (name, password, email, website, bio) VALUES ('".addslashes($name)."', '".$pwd."', '".addslashes($email)."', '".addslashes($website)."', '".addslashes($bio)."')";
|
|
|
|
if ($mysqli->query($sql) === TRUE) {
|
|
echo "{\"string\":Success}";
|
|
} else {
|
|
echo "{\"string\":Error}";
|
|
}
|
|
|
|
} else {
|
|
echo "{\"string\":User already exists.}";
|
|
}
|
|
|
|
$mysqli->close();
|
|
?>
|