functions.php
PHP Code:
<?php
$server = "127.0.0.1:3307";
$user = "root";
$password = "";
$_data = "_data";
$_db = "_db";
$_auth = "_auth";
$_post = "_post";
$pwsalt = "phoohie1yaihooyaequae7PuiWoeNgahjieth3ru3yeeghaepahb7aeYaipe2we6zii6mai6uweig8siasheinoungeoyeiLohShi2xoh2xi8ooxee9ahpiehahc9Phe";
$con = mysqli_connect($server, $user, $password) or exit(mysqli_error());
function con_data () {
global $con, $_data;
mysqli_select_db($con, $_data) or exit(mysqli_error());
}
function con_db () {
global $con, $_db;
mysqli_select_db($con, $_db) or exit(mysqli_error());
}
function con_auth () {
global $con, $_auth;
mysqli_select_db($con, $_auth) or exit(mysqli_error());
}
function con_post () {
global $con, $_post;
mysqli_select_db($con, $_post) or exit(mysqli_error());
}
?>
PHP Code:
<link href="css\styles.css" rel="stylesheet" type="text/css" />
<?php include ("footer.php"); ?>
<?php include ("navigation.php"); ?>
<?php include ("slideshow.php"); ?>
<?php include ("functions.php"); ?>
<div class="content">
<?php
con_auth();
if(isset($_GET['register'])) {
$submit = $_POST ['submit'];
$user_id = $_POST ['user_id'];
$password = $_POST ['password'];
$password2 = $_POST ['password2'];
$email = $_POST ['email'];
if ($submit) {
if (empty($_POST['user_id'])) {
echo "<br> [ERROR] Please fill in a username! <br>";
?>
<meta http-equiv='refresh' content='5' ; URL=register.php">
<?php
} elseif (empty($_POST['password'])) {
echo "<br> [ERROR] Please fill in a password! <br>";
?>
<meta http-equiv='refresh' content='5' ; URL=register.php">
<?php
} elseif (empty($_POST['email'])) {
echo "<br> [ERROR] Please fill in a e-mail! <br>";
?>
<meta http-equiv='refresh' content='5' ; URL=register.php">
}
<?php
die;
if (($_POST['password']) != ($_POST['password2'])) {
echo "<br> [ERROR] Password must the same as Repeat Password!<br>";
?>
<meta http-equiv='refresh' content='5' ; URL=register.php">
<?php
die;
}
$con = new mysqli($server, $user, $password, $db_auth);
$mailresult = "SELECT * FROM bg_user WHERE email = '$email'";
$mailres = $con->query($mailresult);
if ($mailres->num_rows > 0) {
echo "<br> [ERROR] E-mail is already linked to another account. Please choose a new e-mail! <br>";
?>
<meta http-equiv='refresh' content='5' ; URL=register.php">
<?php
die;
}
$user_result = "SELECT * FROM bg_user WHERE user_id = '" . $user_id . "';";
$userres = $con->query($user_result);
If ($userres->num_rows > 0) {
echo " <br> [ERROR] Accountname is in use! Please choose another account name! ";
?>
<meta http-equiv='refresh' content='5' ; URL=register.php">
<?php
die;
} else {
$cryptpasswd = hash("sha256", $user_id . $salt . $password);
$queryreg = mysqli_query("INSERT INTO bg_user (user_id, passwd, email)
VALUES ('$user_id', '$cryptpasswd', '$email')");
echo " <br>Succes ! Account created ! <br>";
}
}
}
}
?>
<br/>
<form action='register.php' method='POST'>
Username:<br/>
<input type='text' class="texta" name='user_id' size="30" maxlength="12">
<br/>
Password:<br/>
<input type='password' class="texta" name='password' size="30" maxlength="12">
<br/>
Repeat Password:<br/>
<input type='password' class="texta" name='password2' size="30" maxlength="12">
<br/>
Email:<br/>
<input type='text' class="texta" name='email' size="30" maxlength="12">
<br>
<br/>
<input type='submit' class="buttonz" name='submit' style='padding:0px; padding-right: 0px; font-size:14px; ' value=' Register '>
</form>
</div>