55ok
| Direktori : /home/u307599615/domains/costumeonrent.in/public_html/ |
| Current File : /home/u307599615/domains/costumeonrent.in/public_html/register.php |
<?php
ob_start(); // Start output buffering to prevent header issues
include("admin/connection.php");
// Handle registration form submission
if (isset($_POST['register'])) {
$Name = mysqli_real_escape_string($con, $_POST['Name']);
$Phone = mysqli_real_escape_string($con, $_POST['Phone']);
$Email = mysqli_real_escape_string($con, $_POST['Email']);
$Password = mysqli_real_escape_string($con, md5($_POST['Password']));
// Check if user already exists
$query = mysqli_query($con, "SELECT * FROM `register` WHERE `Email` = '$Email'") or die('Query failed');
if (mysqli_num_rows($query) > 0) {
$message[] = 'User already exists!';
} else {
// Insert new user
mysqli_query($con, "INSERT INTO `register`(`Name`, `Phone`, `Email`, `Password`) VALUES ('$Name','$Phone','$Email','$Password')") or die('Insert query failed!');
// Redirect to signin page
header('Location: login.php');
exit();
}
}
?>
<?php
include('include/header.php');
?>
<!-- Register Page -->
<div class="register-container">
<?php
if (isset($message)) {
foreach ($message as $msg) {
echo '<div class="message" onclick="this.remove();">' . $msg . '</div>';
}
}
?>
<h2>Create an Account</h2>
<form action="" method="POST">
<div class="form-group">
<label for="username">Username:</label>
<input type="text" id="username" name="Name" placeholder="Enter your username" required>
</div>
<div class="form-group">
<label for="email">Phone:</label>
<input type="text" id="email" name="Phone" placeholder="Enter your phone" required>
</div>
<div class="form-group">
<label for="email">Email:</label>
<input type="email" id="email" name="Email" placeholder="Enter your email" required>
</div>
<div class="form-group">
<label for="password">Password:</label>
<input type="password" id="password" name="Password" placeholder="Enter your password" required>
</div>
<button type="submit" name="register">Register</button>
<p class="login-link">Already have an account? <a href="login.php">Login here</a></p>
</form>
</div>
<style>
/* Register Page Styles */
.register-container {
max-width: 400px;
margin: 50px auto;
padding: 30px 25px;
background: #f4f4f4;
border-radius: 10px;
box-shadow: 0px 4px 10px rgba(0, 0, 0, 0.1);
font-family: Arial, sans-serif;
}
.register-container h2 {
text-align: center;
margin-bottom: 25px;
color: #333;
}
.form-group {
margin-bottom: 20px;
}
.form-group label {
display: block;
margin-bottom: 6px;
font-weight: 600;
color: #555;
}
.form-group input {
width: 100%;
padding: 10px 12px;
border: 1px solid #ccc;
border-radius: 5px;
font-size: 14px;
}
button[type="submit"] {
width: 100%;
padding: 12px;
background-color: #2a4c9f;
color: white;
font-weight: bold;
border: none;
border-radius: 5px;
cursor: pointer;
font-size: 16px;
transition: background 0.3s ease;
}
button[type="submit"]:hover {
background-color: #1f3873;
}
.login-link {
text-align: center;
margin-top: 15px;
font-size: 14px;
}
.login-link a {
color: #2a4c9f;
text-decoration: none;
}
.login-link a:hover {
text-decoration: underline;
}
</style>
<?php
include('include/footer.php');
?>