keksAccount/resources/views/account/register.php

65 lines
2.7 KiB
PHP

<?php include(__DIR__."/../layout/top.php"); ?>
<div class="row">
<div class="col-md-12">
<h3>Register</h3>
<?php if(!empty($msg)) { ?>
<div class="alert alert-warning" role="alert">
<?php echo $msg; ?>
</div>
<?php } ?>
<form method="post" id="register">
<input name="invite" placeholder="Username" class="form-control" value="<?php echo $invite; ?>" style="display: none;">
<b>Username:</b> <span id="msg_username" class="msg"></span>
<?php
if(!empty($username)) {
?>
<input name="username" placeholder="Username" class="form-control" value="<?php echo $username; ?>" style="display: none;">
<input class="form-control" value="<?php echo $username; ?>" disabled>
<?php
} else {
?>
<input name="username" placeholder="Username" class="form-control" value="<?php echo $username; ?>">
<?php
}
?>
<b>Password:</b> <span id="msg_password" class="msg"></span>
<input name="password" type="password" placeholder="Password" class="form-control">
<b>E-Mail</b> <span id="msg_mail" class="mail"></span>
<input type="email" placeholder="E-Mail" name="mail" class="form-control">
<input type="submit" class="btn btn-success" value="Register" style="margin-top: 10px;">
</form>
</div>
</div>
<script language="JavaScript">
$(document).ready(function () {
console.log("READY");
$("#register").submit(function (e) {
e.preventDefault();
var form = $(this);
$.ajax({
type: "POST",
url: "/gui/register",
data: form.serialize(), // serializes the form's elements.
success: function (data) {
window.location.href = "/gui/login";
},
error: function (data) {
$(".msg").each(function (key, e) {
console.log(e);
$(e).html("");
})
if(data.status == 422) {
$.each(data.responseJSON, function( key, value ) {
$("#msg_"+key).html(value[0]);
});
}
if(data.status == 401) {
alert("Usernamme/Password falsch");
}
}
});
});
});
</script>
<?php include(__DIR__."/../layout/bottom.php"); ?>