14.08.2024

2

Like

30

Views

php-register-page

<?php

// Database connection

$conn = new mysqli('localhost', 'root', '', 'user_auth');


// Check connection

if ($conn->connect_error) {

die("Connection failed: " . $conn->connect_error);

}


// Handle form submission

if ($_SERVER['REQUEST_METHOD'] == 'POST') {

$username = $conn->real_escape_string($_POST['username']);

$email = $conn->real_escape_string($_POST['email']);

$password = password_hash($_POST['password'], PASSWORD_BCRYPT);


$sql = "INSERT INTO users (username, email, password) VALUES ('$username', '$email', '$password')";


if ($conn->query($sql) === TRUE) {

echo "Registration successful!";

} else {

echo "Error: " . $sql . "<br>" . $conn->error;

}

}

?>


<form method="POST" action="">

<input type="text" name="username" placeholder="Username" required><br>

<input type="email" name="email" placeholder="Email" required><br>

<input type="password" name="password" placeholder="Password" required><br>

<button type="submit">Register</button>

</form>


PHP Temel
PHP ile Backend Patikası Projeleri

Comments

You need to log in to be able to comment!

Anıl Baran Yelken

Freelancer web developer Languages ​​I know: Php Bootstrap Node.js React Flask Django https://anilbaran-yelken.blogspot.com/

Location

İzmir, TR

Job Experience

- Freelancer

© 2021 Patika Dev

facebook
twitter
instagram
youtube
linkedin