Skip to content

Instantly share code, notes, and snippets.

@fannyhasbi
Last active September 27, 2018 10:40
Show Gist options
  • Save fannyhasbi/9207537242564e708d0d1c46974d13d0 to your computer and use it in GitHub Desktop.
Save fannyhasbi/9207537242564e708d0d1c46974d13d0 to your computer and use it in GitHub Desktop.
Dasar halaman daftar
<?php
if(isset($_POST['daftar'])){
$username = $_POST['username'];
$password = $_POST['password'];
$password = password_hash($password, PASSWORD_BCRYPT);
require_once "./koneksi.php";
$sql = "INSERT INTO user (username, password) VALUES ('$username', '$password')";
$query = mysqli_query($connect, $sql);
if($query){
header('Location: ./index.php');
}
else {
die('Error');
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Daftar</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
</head>
<body>
<div class="container-fluid">
<div class="jumbotron alert-info text-center">
<h1>Daftar</h1>
</div>
<div class="row">
<div class="col-md-4 col-md-offset-4">
<form action="" method="post">
<div class="form-group">
<label for="username" class="control-label">Username</label>
<input type="text" name="username" class="form-control">
</div>
<div class="form-group">
<label for="password" class="control-label">Password</label>
<input type="password" name="password" class="form-control">
</div>
<div class="form-group">
<input type="submit" name="daftar" class="btn btn-success">
</div>
</form>
</div>
</div>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment