0% found this document useful (0 votes)
11 views

!doctype HTML

Uploaded by

Defi Saaa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views

!doctype HTML

Uploaded by

Defi Saaa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

<!

DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Nest Dashboard</title>
<meta http-equiv="x-ua-compatible" content="ie=edge" />
<meta name="description" content="" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta property="og:title" content="" />
<meta property="og:type" content="" />
<meta property="og:url" content="" />
<meta property="og:image" content="" />
<!-- Favicon -->
<link rel="shortcut icon" type="image/x-icon" href="upload/bbb.svg" />
<!-- Template CSS -->
<link href="assets/css/main.css?v=1.1" rel="stylesheet" type="text/css" />
</head>
<body>
<?php
include "config.php";
if(isset($_POST['daftar'])){
$nama = $_POST['nama'];
$email = $_POST['email'];
$no_tlp = $_POST['no_tlp'];
$password = md5($_POST['password']);
$foto = $_FILES['foto']['name'];
$tmp = $_FILES['foto']['tmp_name'];
$path = "upload/".$foto;

// Validasi input
if(empty($nama) || empty($email) || empty($no_tlp) || empty($password)) {
echo '<script>window.alert("Semua field harus diisi!");
window.location.href="?page=daftar"</script>';
} else {
// Cek apakah email sudah terdaftar
$cek = mysqli_query($koneksi, "SELECT * FROM customer2 WHERE
email='$email'");
if (mysqli_num_rows($cek) > 0) {
echo '<script>window.alert("Email sudah terdaftar!");
window.location.href="?page=daftar"</script>';
} else {
// Query untuk menyimpan data registrasi ke database
$query = "INSERT INTO customer2 (nama, email, no_tlp, password, foto)
VALUES ('$nama', '$email', '$no_tlp', '$password', '$foto')";
$result = mysqli_query($koneksi, $query);

if($result){
move_uploaded_file($tmp,$path);
echo '<script>window.alert("Registrasi berhasil!");
window.location.href="utama.php?page=login"</script>';
} else {
echo '<script>window.alert("Registrasi gagal!");
window.location.href="?page=daftar"</script>';
}
}
}
}
?>
<section class="content-main mt-80 mb-80">
<div class="card mx-auto card-login">
<div class="card-body">
<h4 class="card-title mb-4">Daftar</h4>
<form action="?page=daftar" method="post"
enctype="multipart/form-data">
<div class="mb-3">
<input class="form-control" name="nama"
placeholder="Nama" type="text" required />
</div>
<!-- form-group// -->
<div class="mb-3">
<input class="form-control" name="email"
placeholder="Email" type="email" required />
</div>
<!-- form-group// -->
<div class="mb-3">
<input class="form-control" name="no_tlp"
placeholder="No Tlp" type="text" required />
</div>
<!-- form-group// -->
<div class="mb-3">
<input class="form-control" name="password"
placeholder="Password" type="password" required />
</div>
<!-- form-group// -->
<div class="mb-3">
<input class="form-control" name="foto" type="file"
required />
</div>
<!-- form-group// -->
<div class="mb-4">
<button type="submit" name="daftar" value="Daftar"
class="btn btn-primary w-100">Daftar</button>
</div>
<div class="mb-4">
<button type="button" class="btn btn-primary w-100
mt-2" onclick="window.location.href='login.php'">Login</button>
</div>
</div>
</div>
</section>
</body>
</html>

You might also like