Sss register html gmail

Here is an example of how to register a user with HTML and Gmail:

HTML Form

<form action="register.php" method="post">
  <label for="username">Username:</label>
  <input type="text" id="username" name="username"><br><br>
  <label for="email">Email:</label>
  <input type="email" id="email" name="email"><br><br>
  <label for="password">Password:</label>
  <input type="password" id="password" name="password"><br><br>
  <input type="submit" value="Register">
</form>

PHP Script (register.php)

<?php
// Connect to database
$conn = mysqli_connect("localhost", "username", "password", "database");

// Check connection
if (!$conn) {
  die("Connection failed: ". mysqli_connect_error());
}

// Get form data
$username = $_POST["username"];
$email = $_POST["email"];
$password = $_POST["password"];

// Check if email already exists
$query = "SELECT * FROM users WHERE email = '$email'";
$result = mysqli_query($conn, $query);
if (mysqli_num_rows($result) > 0) {
  echo "Email already exists!";
  exit;
}

// Hash password
$password_hash = password_hash($password, PASSWORD_DEFAULT);

// Insert user into database
$query = "INSERT INTO users (username, email, password) VALUES ('$username', '$email', '$password_hash')";
mysqli_query($conn, $query);

// Send verification email
$subject = "Verify your email address";
$message = "Hello $username, please click on the following link to verify your email address: <a href='https://example.com/verify.php?email=$email'>Verify Email</a>";
$headers = "From: [email protected]". "\r\n". "Reply-To: [email protected]". "\r\n". "MIME-Version: 1.0". "\r\n". "Content-Type: text/html; charset=UTF-8";
mail($email, $subject, $message, $headers);

// Redirect to login page
header("Location: login.php");
exit;
?>

Gmail SMTP Settings

To send the verification email using Gmail, you'll need to set up the SMTP settings in your PHP script. Here's an example:

// Gmail SMTP settings
$smtp_host = "smtp.gmail.com";
$smtp_port = 587;
$smtp_username = "your-gmail-username";
$smtp_password = "your-gmail-password";

Make sure to replace your-gmail-username and your-gmail-password with your actual Gmail credentials.

Note: To use Gmail's SMTP server, you'll need to allow less secure apps to access your account. You can do this by going to your Google Account settings and enabling the "Less secure app access" option.