Hi! Could we please enable some services and cookies to improve your experience and our website?
No, thanks.
Okay!
Online Sandbox for SQL and PHP: Write, Run, Test, and Share SQL Queries and PHP Code
-- Database: your_dbname (replace with your actual database name)
CREATE TABLE users (
id INT AUTO_INCREMENT PRIMARY KEY,
username VARCHAR(255) UNIQUE NOT NULL,
password VARCHAR(255) NOT NULL,
email VARCHAR(255) UNIQUE NOT NULL,
registration_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
SQL Server:
MySQL 8.0
MySQL 8.0 Sakila (ReadOnly)
MySQL 9.3.0
MariaDB 11.4
MariaDB 11.8
MariaDB 10
MariaDB 10 Sakila (ReadOnly)
SQLite 3
SQLite 3 Preloaded
PostgreSQL 10 Bookings (ReadOnly)
PostgreSQL 13
PostgreSQL 14
PostgreSQL 15
PostgreSQL 16
PostgreSQL 17 + PostGIS
PostgreSQL 17 + PostGIS WorkShop (ReadOnly)
MS SQL Server 2017
MS SQL Server 2019
MS SQL Server 2022
MS SQL Server 2022 AdventureWorks (ReadOnly)
Firebird 4.0
Firebird 4.0 (Employee)
RedDatabase 5.0
Oracle Database 19c (HR)
Oracle Database 21c
Oracle Database 23c Free
SOQOL
ClickHouse
Run SQL code
Save snippet
ER Diagram
<?php
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Dance Competition Registration Form</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f2f2f2;
}
form {
max-width: 400px;
margin: 0 auto;
background-color: #fff;
padding: 20px;
border-radius: 5px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
input[type="text"],
input[type="password"],
input[type="email"],
textarea,
select {
width: 100%;
padding: 10px;
margin: 5px 0;
border: 1px solid #ccc;
border-radius: 4px;
box-sizing: border-box;
}
input[type="radio"] {
margin-right: 5px;
}
input[type="submit"] {
background-color: #4CAF50;
color: white;
padding: 10px 20px;
border: none;
border-radius: 4px;
cursor: pointer;
font-size: 16px;
}
input[type="submit"]:hover {
background-color: #45a049;
}
.error {
color: red;
}
</style>
</head>
<body>
<form id="registrationForm" method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>">
<label for="username">Username:</label>
<input type="text" id="username" name="username">
<label for="password">Password:</label>
<input type="password" id="password" name="password">
<label for="confirmPassword">Confirm Password:</label>
<input type="password" id="confirmPassword" name="confirmPassword">
<label for="email">Email Address:</label>
<input type="email" id="email" name="email">
<label for="mobile">Mobile Number:</label>
<input type="text" id="mobile" name="mobile">
<label>Gender:</label>
<input type="radio" id="male" name="gender" value="Male">
<label for="male">Male</label>
<input type="radio" id="female" name="gender" value="Female">
<label for="female">Female</label>
<input type="radio" id="other" name="gender" value="Other">
<label for="other">Other</label>
<label for="dob">Date of Birth:</label>
<input type="date" id="dob" name="dob">
<label for="address">Address:</label>
<textarea id="address" name="address"></textarea>
<input type="submit" value="Submit">
</form>
<script>
document.getElementById("registrationForm").addEventListener("submit", function(event) {
var isValid = true;
// Validate email format
var email = document.getElementById("email").value;
var emailPattern = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
if (!emailPattern.test(email)) {
isValid = false;
document.getElementById("email").classList.add("error");
} else {
document.getElementById("email").classList.remove("error");
}
// Validate mobile number (accept only 10 digits)
var mobile = document.getElementById("mobile").value;
var mobilePattern = /^\d{10}$/;
if (!mobilePattern.test(mobile)) {
isValid = false;
document.getElementById("mobile").classList.add("error");
} else {
document.getElementById("mobile").classList.remove("error");
}
if (!isValid) {
event.preventDefault(); // Prevent form submission if validation fails
}
});
</script>
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$username = $_POST['username'];
$email = $_POST['email'];
$mobile = $_POST['mobile'];
$gender = $_POST['gender'];
$dob = $_POST['dob'];
$address = $_POST['address'];
// Validate email format
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
echo "<p class='error'>Invalid email format</p>";
} else {
echo "<p>Username: $username</p>";
echo "<p>Email: $email</p>";
echo "<p>Mobile: $mobile</p>";
echo "<p>Gender: $gender</p>";
echo "<p>Date of Birth: $dob</p>";
echo "<p>Address: $address</p>";
}
}
?>
</body>
</html>
PHP version :
PHP 7.4
PHP 8.0
PHP 8.1
PHP 8.2
PHP 8.3
PHP 8.4
Run PHP Code
Save snippet