87 lines
3.4 KiB
PHP
87 lines
3.4 KiB
PHP
<?php
|
|
namespace core;
|
|
use \PDO as PDO;
|
|
require_once 'core/classes.php';
|
|
use classes\PartyStarter as PartyStarter;
|
|
|
|
$getitstarted = new PartyStarter;
|
|
$getitstarted->buildloggedoutheader();
|
|
$passwordconfirmiswrong = "false";
|
|
if(isset($_POST['submit'])) {
|
|
$username = $_POST['username'];
|
|
$password = $_POST['pass'];
|
|
$passwordconfirm = $_POST['passconfirm'];
|
|
echo "ur username: " . $username;
|
|
echo "<br/>";
|
|
echo "ur password: " . $password;
|
|
echo "<br/>";
|
|
echo "ur passwordconfirm: " . $passwordconfirm;
|
|
if ($password == $passwordconfirm) {
|
|
echo '<script>
|
|
if ( window.history.replaceState ) {
|
|
window.history.replaceState( null, null, window.location.href );
|
|
}
|
|
</script>';
|
|
echo "confirm pass is correct";
|
|
if (strlen($password) < 8) {
|
|
$passwordistooshort = "true";
|
|
}
|
|
if (strlen($password) > 8) {
|
|
$passwordistooshort = "false";
|
|
}
|
|
if ($passwordistooshort == "false") {
|
|
$hashed = password_hash($password, PASSWORD_DEFAULT);
|
|
echo $hashed;
|
|
$getitstarted->db();
|
|
$checkusername = $db->prepare('SELECT * FROM users WHERE username=(username) VALUES (:username)');
|
|
$checkusername->execute([ 'username' => $username ]);
|
|
if (mysqli_num_rows($checkusername) > 0) {
|
|
echo "bruh momento";
|
|
}else if(mysqli_num_rows($checkusername) < 0){
|
|
echo "hello romania";
|
|
}
|
|
}
|
|
} else {
|
|
$passwordconfirmiswrong = "true";
|
|
echo '<script>
|
|
if ( window.history.replaceState ) {
|
|
window.history.replaceState( null, null, window.location.href );
|
|
}
|
|
</script>';
|
|
}
|
|
}
|
|
$result = file_get_contents("https://useless-facts.sameerkumar.website/api");
|
|
$thefunfact = json_decode($result);
|
|
?>
|
|
<link rel="stylesheet" href="css/register.css">
|
|
<form action="" method="post">
|
|
<div class="card mb-3">
|
|
<h3 class="card-header">Registration</h3>
|
|
</svg>
|
|
<div class="card-body">
|
|
<label class="col-form-label col-form-label-sm mt-4 username" for="inputSmall">Username</label>
|
|
<input class="form-control form-control-sm" type="text" placeholder="Your username" id="inputSmall" for="inputValid" name="username">
|
|
<label class="col-form-label col-form-label-sm mt-4 password" for="inputSmall">Password</label>
|
|
<input class="<?php if($passwordconfirmiswrong == "true") {
|
|
echo "form-control is-invalid";
|
|
} else {
|
|
echo "form-control form-control-sm";
|
|
} ?>" type="password" placeholder="Your password (Minmum 8 characters)" id="inputSmall" name="pass">
|
|
<?php if($passwordconfirmiswrong == "true") {
|
|
echo '<div class="invalid-feedback" bis_skin_checked="1">Password Confirmation field is invalid.</div>';
|
|
} else if ($passwordistooshort == "true") {
|
|
echo '<div class="invalid-feedback" bis_skin_checked="1">Password is too short. (8 Characters minmum)</div>';
|
|
}?>
|
|
<label class="col-form-label col-form-label-sm mt-4 passwordconfirm" for="inputSmall">Password Confirmation</label>
|
|
<input class="form-control form-control-sm" type="password" placeholder="Enter your password again" id="inputSmall" name="passconfirm">
|
|
<button type="submit" class="btn btn-secondary" name="submit">Register</button>
|
|
</div>
|
|
</div>
|
|
</form>
|
|
<div class="card text-white bg-dark mb-3" style="max-width: 20rem;">
|
|
<div class="card-header">Random useless fact generator</div>
|
|
<div class="card-body">
|
|
<p class="card-text"><?php echo $thefunfact->{"data"}; ?></p>
|
|
</div>
|
|
</div>
|