PHPize Online / SQLize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
CREATE DATABASE form_application; USE form_application; CREATE TABLE users ( id INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(100) NOT NULL, email VARCHAR(100) NOT NULL, created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP );
Copy Clear
Copy Format Clear
<?php include 'db_connection.php'; if ($_SERVER["REQUEST_METHOD"] == "POST") { // Collect and sanitize input data $name = $conn->real_escape_string($_POST['name']); $email = $conn->real_escape_string($_POST['email']); // Insert data into the database $sql = "INSERT INTO users (name, email) VALUES ('$name', '$email')"; if ($conn->query($sql) === TRUE) { echo "New record created successfully"; } else { echo "Error: " . $sql . "<br>" . $conn->error; } // Redirect to the main page header("Location: index.php"); exit(); } ?>
Show:  
Copy Clear