2 answers
Best answer
<form>
<label for="fname">First name:</label><br>
<input type="text" id="fname" name="fname"><br>
<label for="lname">Last name:</label><br>
<input type="text" id="lname" name="lname">
</form>
<label for="fname">First name:</label><br>
<input type="text" id="fname" name="fname"><br>
<label for="lname">Last name:</label><br>
<input type="text" id="lname" name="lname">
</form>
codelikepro
· 19 Aug 2022
Report
Was this answer helpful?
Thanks for the feedback.
Sign up free to save answers and ask your own doubts
Create the form in HTML and send its data to a server-side script (for example PHP) that inserts it into a MySQL table.
1. Table in MySQL
CREATE TABLE users (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(50), email VARCHAR(100),
password VARCHAR(255)
);2. HTML form (register.html)
<form action="register.php" method="post">
Name: <input type="text" name="name" required><br>
Email: <input type="email" name="email" required><br>
Password: <input type="password" name="password" required><br>
<input type="submit" value="Register">
</form>3. PHP script (register.php)
<?php
$conn = new mysqli("localhost", "root", "", "mydb");
if ($conn->connect_error) die("Connection failed");
$hash = password_hash($_POST["password"], PASSWORD_DEFAULT);
$stmt = $conn->prepare(
"INSERT INTO users (name, email, password) VALUES (?, ?, ?)");
$stmt->bind_param("sss", $_POST["name"], $_POST["email"], $hash);
echo $stmt->execute() ? "Registered successfully" : "Error";
$conn->close();
?>HTML alone cannot talk to a database. The form's action sends the data by POST to register.php, which connects to MySQL and stores it. The prepared statement prevents SQL injection, and password_hash() stores the password safely. Run it on a server such as XAMPP/WAMP.
Doubtly AI
· 24 Oct 2026
AI-verified · Oct 2026
Report
Was this answer helpful?
Thanks for the feedback.
Sign up free to save answers and ask your own doubts
Your answer
Log in or create a free account to answer this question.