Registering + Config + Code Cleanup
This commit is contained in:
parent
ba6d9198d3
commit
d301e82aeb
|
|
@ -0,0 +1 @@
|
|||
@cmd
|
||||
|
|
@ -13,12 +13,12 @@ class PartyStarter {
|
|||
echo '<link rel="stylesheet" href="css/bootstrap.min.css">
|
||||
<nav class="navbar navbar-expand-lg navbar-light" style="background-color: #ff7700;">
|
||||
<div class="container-fluid">
|
||||
<a class="navbar-brand" href="/">undefined</a>
|
||||
<a class="navbar-brand" href="/"><img src="https://i.ytimg.com/vi/eAx4X7UtLoE/maxresdefault.jpg" width="30" height="30" class="d-inline-block align-top" alt=""> Grublox</a>
|
||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarColor03" aria-controls="navbarColor03" aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
<div class="collapse navbar-collapse" id="navbarColor03">
|
||||
<ul class="navbar-nav me-auto" style="color: #FFFFFF;">
|
||||
<ul class="navbar-nav me-auto ml-auto" style="color: #FFFFFF;">
|
||||
<li class="nav-item" style="color: #FFFFFF;">
|
||||
<a class="nav-link active" href="/home">Home</a>
|
||||
<span class="visually-hidden">(current)</span>
|
||||
|
|
@ -48,10 +48,8 @@ class PartyStarter {
|
|||
</div>
|
||||
</nav>';
|
||||
}
|
||||
function db() {
|
||||
$db = new \PDO('mysql:dbname=undefined;host=127.0.0.1;charset=utf8mb4', 'root', '');
|
||||
$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
|
||||
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
}
|
||||
|
||||
// Contributed by qzip! remove if noob.
|
||||
|
||||
}
|
||||
?>
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
<?php
|
||||
try {
|
||||
$con = new PDO("mysql:dbname=grublox;host=localhost", "root", "");
|
||||
$con->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
|
||||
}
|
||||
catch (PDOException $e) {
|
||||
echo "Connection failed: " . $e->getMessage();
|
||||
}
|
||||
72
register.php
72
register.php
|
|
@ -1,12 +1,12 @@
|
|||
<?php
|
||||
namespace core;
|
||||
use \PDO as PDO;
|
||||
require_once 'core/classes.php';
|
||||
use classes\PartyStarter as PartyStarter;
|
||||
require_once 'core/config.php';
|
||||
|
||||
$getitstarted = new PartyStarter;
|
||||
$getitstarted->buildloggedoutheader();
|
||||
$passwordconfirmiswrong = "false";
|
||||
$passwordconfirmiswrong = false;
|
||||
$passwordistooshort = false;
|
||||
if(isset($_POST['submit'])) {
|
||||
$username = $_POST['username'];
|
||||
$password = $_POST['pass'];
|
||||
|
|
@ -16,43 +16,42 @@ if(isset($_POST['submit'])) {
|
|||
echo "ur password: " . $password;
|
||||
echo "<br/>";
|
||||
echo "ur passwordconfirm: " . $passwordconfirm;
|
||||
echo "<br/>";
|
||||
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";
|
||||
}
|
||||
}
|
||||
$passwordconfirmiswrong = false;
|
||||
} else {
|
||||
$passwordconfirmiswrong = "true";
|
||||
echo '<script>
|
||||
if ( window.history.replaceState ) {
|
||||
window.history.replaceState( null, null, window.location.href );
|
||||
}
|
||||
</script>';
|
||||
$passwordconfirmiswrong = true;
|
||||
}
|
||||
|
||||
if (strlen($password) < 8) {
|
||||
$passwordistooshort = true;
|
||||
} else {
|
||||
$passwordistooshort = false;
|
||||
}
|
||||
if ($passwordistooshort == false && $passwordconfirmiswrong == false) {
|
||||
$password = password_hash($password, PASSWORD_DEFAULT);
|
||||
echo $password;
|
||||
echo "<br/>";
|
||||
$query = $con->prepare('SELECT COUNT(*) FROM users WHERE username=:username');
|
||||
$query->bindParam(':username', $username);
|
||||
$query->execute();
|
||||
$result = $query->fetchColumn();
|
||||
if ($result == 0) {
|
||||
echo "No results, continue. ";
|
||||
$query = $con->prepare('INSERT INTO users (username, password) VALUES (:username, :password)');
|
||||
$query->bindParam(':username', $username);
|
||||
$query->bindParam(':password', $password);
|
||||
$query->execute();
|
||||
} else {
|
||||
echo "Nope, you stay.";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
$result = file_get_contents("https://useless-facts.sameerkumar.website/api");
|
||||
$thefunfact = json_decode($result);
|
||||
?>
|
||||
<div class="bg-dark">
|
||||
<link rel="stylesheet" href="css/register.css">
|
||||
<form action="" method="post">
|
||||
<div class="card mb-3">
|
||||
|
|
@ -62,14 +61,14 @@ $thefunfact = json_decode($result);
|
|||
<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") {
|
||||
<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") {
|
||||
<?php if($passwordconfirmiswrong == true) {
|
||||
echo '<div class="invalid-feedback" bis_skin_checked="1">Password Confirmation field is invalid.</div>';
|
||||
} else if ($passwordistooshort == "true") {
|
||||
} 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>
|
||||
|
|
@ -84,3 +83,4 @@ echo "form-control form-control-sm";
|
|||
<p class="card-text"><?php echo $thefunfact->{"data"}; ?></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Reference in New Issue