Untitled

 avatar
unknown
plain_text
2 years ago
3.6 kB
2
Indexable
<!DOCTYPE html>
<html lang="en">
	<head>
		<link rel="stylesheet" type="text/css" href="bootstrap-4.6.2-dist/css/bootstrap.css"/>
		<link rel="stylesheet" href="css/css.css">
		<meta charset="UTF-8" name="viewport" content="width=device-width, initial-scale=1"/>
	</head>
<body>
	<?php include 'navbar.php';?>
		<div class="container-fluid">
			
		
	</nav>
	<div class="col-md-3"></div>
	<div class="col-md-6 well">
		<h3 class="text-primary">PDO-LOGIN</h3>
		<hr style="border-top:1px dotted #ccc;"/>
		<div class="col-md-2"></div>
		<div class="col-md-8">
			<form action="register_query.php" method="POST">	
				<h4 class="text-success">Please Register Here...</h4>
				<hr style="border-top:1px groovy #000;">
				<div class="form-group">
					<label>Firstname</label>
					<input type="text" class="form-control" name="firstname" required />
				</div>
				<div class="form-group">
					<label>Lastname</label>
					<input type="text" class="form-control" name="lastname" required />
				</div>
				<div class="form-group">
					<label>Username</label>
					<input type="text" class="form-control" name="username" required />
				</div>
				<div class="form-group">
					<label>Password</label>
					<input type="password" class="form-control" name="password" required />
				</div>
				<br>
				<hr style="border-top:1px groovy #000;">
				<div class="form-group">
					<button class="btn btn-primary form-control" name="register">Register</button>
				</div>
				<p class="text-primary" align="center">---------or----------</p>
				
				<a  href="index.php">Already have an users?</a>
			</form>
		</div>
	</div>
</body>
</html>

<!-- </html> -->
<!--
<?php
require_once 'config.php';

if (isset($_POST['insert'])) {
    $username = $_POST['username'];
    $lastname = $_POST['lastname'];
    $password = $_POST['password'];
    $confirm_password = $_POST['confirm_pass'];

    // Check if password and confirm password match
    if ($password !== $confirm_password) {
         ?>
        <div class="header" id="alerts">
        <div class="alert alert-danger alert-dismissible fade show" role="alert">
          Password does not match.
         </div>
        </div>
        <?php
  
        exit();

    }

    // Check if username already exists in the database
    $sql = "SELECT COUNT(*) as count FROM users WHERE username = :username";
    $stmt = $dbh->prepare($sql);
    $stmt->bindParam(':username', $username, PDO::PARAM_STR);
    $stmt->execute();
    $result = $stmt->fetch(PDO::FETCH_ASSOC);
    if ($result['count'] > 0) {
       ?>
        <div class="header" id="alerts">
        <div class="alert alert-danger alert-dismissible fade show" role="alert">
          Username already in the database.
         </div>
        </div>
        <?php
        
        exit();
    }

    // Generate MD5 hash of password
    $password = md5($password);

    // Query for Insertion
    $sql = "INSERT INTO users (uname,password) VALUES (:username, :password)";
    $stmt = $dbh->prepare($sql);
    $stmt->bindParam(':username', $username, PDO::PARAM_STR);
    $stmt->bindParam(':password', $password, PDO::PARAM_STR);
    $stmt->execute();

    // Check if insertion was successful
    $lastInsertId = $dbh->lastInsertId();
    if ($lastInsertId) {
          ?>
        <div class="header" id="alerts">
        <div class="alert alert-success alert-dismissible fade show" role="alert">
          Register successful!
        </div>
        </div>
        <?php
        header('refresh:1.5, url=index.php');
    }
}
?>
 -->
</html>




Editor is loading...