<?php

require_once(dirname(__FILE__) . '\header.php');
if (isset($_POST["register"])) {
	if (registrasi($_POST) > 0) {
		echo "<script>
					alert('user baru berhasil ditambahkan! Silahkan lakukan Login');
					document.location.href = 'login.php';
                </script>";
	} else {
		echo mysqli_error($conn);
	}
}
?>
<!DOCTYPE html>
<html>

<head>

	<!-- Bootstrap CSS -->
	<link rel="stylesheet" href="css/bootstrap.min.css">

	<!-- CSS yang saya tambahkan -->
	<link rel="stylesheet" href="css/style.css">

	<title>Daftar Akun E-Complaint</title>
	<style>
		button {
			margin-top: 20px;
			margin-bottom: 20px;
		}

		input {
			margin-left: 20px;
			width: 350px;
			margin-top: 10px;
		}

		.haha {
			margin-left: -150px;
		}

		.nnn {
			width: 250px;
		}
	</style>
</head>

<body>

	<h2>
		<center>Daftar Akun E-Complaint</center>
	</h2>
	<form action="" method="POST" enctype="multipart/form-data">
		<div class="container">
			<div class="form-group row">
				<label for="nama" class="col-sm-2 col-form-label">Nama Lengkap</label>
				<div class="col-sm-10">
					<input type="text" class="form-control" name="nama" id="nama" required>
				</div>
			</div>
			<div class="form-group row">
				<label for="alamat" class="col-sm-2 col-form-label">Alamat Lengkap</label>
				<div class="col-sm-10">
					<input type="text" class="form-control" name="alamat" id="alamat" required>
				</div>
			</div>
			<div class="form-group row">
				<label for="nim" class="col-sm-2 col-form-label">NIK</label>
				<div class="col-sm-10">
					<input type="text" class="form-control" name="nim" id="nim" required>
				</div>
			</div>
			<div class="form-group row">
				<label for="lahir" class="col-sm-2 col-form-label">Tempat/Tanggal Lahir</label>
				<div class="col-sm-10">
					<input type="text" class="nnn" name="tempat" id="tempat" placeholder="Tempat..." required>
					<!-- membuat tanggal lahir -->
					<select id="tanggal" name="tanggal" required>
						<option id="tanggal" name="tanggal" value="">Date</option>
						<?php
						$x = 31;
						for ($i = 1; $i <= $x; $i++) : ?>
							<option id="tanggal" name="tanggal" value="<?php echo $i; ?>"><?php echo $i; ?></option>
						<?php endfor; ?>
					</select>
					<!-- membuat bulan lahir -->
					<select id="bulan" name="bulan" required>
						<option id="bulan" name="bulan" value="">Month</option>
						<option id="bulan" name="bulan" value="January">January</option>
						<option id="bulan" name="bulan" value="February">February</option>
						<option id="bulan" name="bulan" value="March">March</option>
						<option id="bulan" name="bulan" value="April">April</option>
						<option id="bulan" name="bulan" value="May">May</option>
						<option id="bulan" name="bulan" value="June">June</option>
						<option id="bulan" name="bulan" value="July">July</option>
						<option id="bulan" name="bulan" value="August">August</option>
						<option id="bulan" name="bulan" value="September">September</option>
						<option id="bulan" name="bulan" value="October">October</option>
						<option id="bulan" name="bulan" value="November">November</option>
						<option id="bulan" name="bulan" value="December">December</option>
					</select>
					<!-- membuat tahun lahir -->
					<select id="tahun" name="tahun" required>
						<option id="tahun" name="tahun" value="">Year</option>
						<?php
						$x = 2020;
						for ($i = 1993; $i <= $x; $i++) : ?>
							<option id="tahun" name="tahun" value="<?php echo $i; ?>"><?php echo $i; ?></option>
						<?php endfor; ?>
					</select>
				</div>
			</div>
			<fieldset class="form-group">
				<div class="row">
					<legend class="col-form-label col-sm-2 pt-0">Jenis Kelamin</legend>
					<div class="col-sm-10">
						<div class="form-check">
							<input class="form-check-input" type="radio" name="jenis" id="jenis" value="L" checked>
							<label class="form-check-label" for="gridRadios1">
								Laki-laki
							</label>
						</div>
						<div class="form-check">
							<input class="form-check-input" type="radio" name="jenis" id="jenis" value="P">
							<label class="form-check-label" for="gridRadios2">
								Perempuan
							</label>
						</div>
					</div>
				</div>
			</fieldset>
			<div class="form-group row">
				<label for="telepon" class="col-sm-2 col-form-label">No. Telepon</label>
				<div class="col-sm-10">
					<input type="text" class="form-control" name="telepon" id="telepon" required>
				</div>
			</div>
			<div class="form-group row">
				<label for="email" class="col-sm-2 col-form-label">Email</label>
				<div class="col-sm-10">
					<input type="email" class="form-control" name="email" id="email" required>
				</div>
			</div>
			<div class="form-group row">
				<label for="kerja" class="col-sm-2 col-form-label">Pekerjaan</label>
				<div class="col-sm-10">
					<input type="text" class="form-control" name="kerja" id="kerja" required>
				</div>
			</div>
			<div class="form-group row">
				<label for="username" class="col-sm-2 col-form-label">Username</label>
				<div class="col-sm-10">
					<input type="text" class="form-control" name="username" id="username" required>
				</div>
			</div>
			<div class="form-group row">
				<label for="password" class="col-sm-2 col-form-label">Password</label>
				<div class="col-sm-10">
					<input type="password" class="form-control" name="password" id="password" required>
				</div>
			</div>
			<div class="form-group row">
				<label for="password2" class="col-sm-2 col-form-label">Konfirmasi Password</label>
				<div class="col-sm-10">
					<input type="password" class="form-control" name="password2" id="password2">
				</div>
			</div>
			<div class="form-group">
				<label for="gambar">Masukkan Foto</label>
				<input type="file" class="form-control-file" id="gambar" name="gambar" required>
			</div>
			<div class="form-group row">
				<div class="col-sm-10">
					<center>
						<button type="submit" class="btn btn-primary" name="register">Submit</button>
					</center>
				</div>
			</div>
		</div>
	</form>

	<p align="center">Already have on account? <a href="login.php">Login</a></p>
	<?php
	require_once(dirname(__FILE__) . '\footer.php');
	?>
</body>

</html>