Basically i have little problem with this code , it fetches all tables from DB correctly and i can create an account ( at least it lets me on the website ) but it will not put it into DB for some reason, so it says acc created succesfully but can't login with it. when i create an acc throuhg db itself, it lets me log in to the website somehow....
@ EDIT repairing account table helped ... (i mean duplicate -> delete ->rename )
<div class="page-header">
<h1>Register</h1>
</div>
<?php
if(isset($_SESSION['id'])) {
?>
<div class="alert alert-warning" role="alert">
To create acc you need to be <a href="index.php?page=logout">Logout</a>.
</div>
<?php
} else {
?>
<?php
//Verificare daca inregistrarea e dezactivata.
$rg = mysqli_query($sqlHp, "SELECT * FROM ".SQL_HP_DB.".settings WHERE id=8");
$reg = mysqli_fetch_assoc($rg);
if ($reg['value'] == 'nu') {
echo '<div class="alert alert-danger" role="alert">
Registration is <strong>OFF</strong>!
</div>'; }
else {
if(!isset($_POST['register'])) {
?>
<div class="alert alert-info" role="alert">
<strong>Warning!</strong> All tables have to be filled in.<br> <strong>Warning!</strong>
e-mail has to be valid!
</div>
<div class="alert alert-danger" role="alert">
<strong>Warning!</strong> By Registering you accept
<a href="index.php?page=rules">T&C</a>.
</div>
<?php } ?>
<?php
if(isset($_POST['register']) && isset($_POST['agreed'])) {
$actions = array(
'username' => sanitize(stripInput($_POST['username'])),
'password' => sanitize(stripInput($_POST['password'])),
'usermail' => sanitize(stripInput($_POST['usermail'])),
'realname' => sanitize(stripInput($_POST['realname'])),
'socialid' => sanitize(stripInput($_POST['socialid'])),
);
$errors = array();
$check_login = "SELECT * FROM account.account WHERE login = '{$actions['username']}'";
$check_login = $sqlServ->query($check_login);
$rows_login = $check_login->num_rows;
$check_email = "SELECT * FROM account.account WHERE email = '{$actions['usermail']}'";
$check_email = $sqlServ->query($check_email);
$rows_email = $check_email->num_rows;
if($rows_login >= 1) {
echo '<div class="alert alert-danger" role="alert">';
echo ' Invalid name!';
echo '</div>';
} else if($rows_email >= 1) {
echo '<div class="alert alert-danger" role="alert">';
echo ' Email is invalid!';
echo '</div>';
} else {
if(filter_var($actions['usermail'], FILTER_VALIDATE_EMAIL)) {
if($_POST['password'] == $_POST['rpassword']) {
$query = "INSERT INTO account.account (login, password, real_name, social_id, email, create_time)
VALUES (?, PASSWORD(?), ?, ?, ?, NOW())";
$sanitize = array(
':user' => $actions['username'],
':pass' => $actions['password'],
':mail' => $actions['usermail'],
':name' => $actions['realname'],
':soid' => $actions['socialid'],
);
$insert = $sqlServ->prepare($query);
$insert->bind_param('sssss', $sanitize[':user'], $sanitize[':pass'], $sanitize[':name'], $sanitize[':soid'], $sanitize[':mail']);
$insert->execute();
echo '<div class="alert alert-success" role="alert">';
echo ' Acc <strong>' . $actions['username'] . '</strong> Created Successfully!';
echo '</div>';
} else {
echo '<div class="alert alert-danger" role="alert">';
echo ' Passwords do not match!';
echo '</div>';
}
} else {
echo '<div class="alert alert-success" role="alert">';
echo ' E-mail not valid!';
echo '</div>';
}
}
}
?>
<div class="well">
<div class="table-responsive">
<form action="<?= $_SERVER['PHP_SELF'] ?>?page=register" method="post">
<table class="table table-striped">
<tbody>
<tr>
<td>Login:</td>
<td><input type="text" class="form-control" name="username" pattern=".{5,16}" maxlength="16" placeholder="Login" required title="5-16 chars"></td>
</tr>
<tr>
<td>Pass:</td>
<td><input type="password" class="form-control" name="password" pattern=".{5,16}" maxlength="16" placeholder="Pass" required title="5-16 chars"></td>
</tr>
<tr>
<td>Repeat Pass:</td>
<td><input type="password" class="form-control" name="rpassword" pattern=".{5,16}" maxlength="16" placeholder="Repeat Pass" required title="5-16 chars"></td>
</tr>
<tr>
<td>E-Mail:</td>
<td><input type="text" class="form-control" name="usermail" pattern=".{7,64}" maxlength="64" placeholder="
[email protected]" required title="max 64 chars."></td>
</tr>
<tr>
<td>Char Del Code:</td>
<td><input type="username" AUTOCOMPLETE="off" maxlength="7" class="form-control" name="socialid" placeholder="7 chars" required></td>
</tr>
<tr>
<td>Name:</td>
<td><input type="username" class="form-control" name="realname" pattern=".{3,15}" maxlength="15" placeholder="Your Name.." required title="max 15 chars."></td>
</tr>
<tr>
<td>I agree to <a href="index.php?page=rules">T&C
</a> <input type="checkbox" name="agreed"></td>
</td>
<td><input type="submit" class="btn btn-s btn-success" name="register" value="Register"></td>
</tr>
</tbody>
</table>
</form>
</div>
</div>
<?php }} ?>