0% found this document useful (0 votes)
6 views6 pages

DOCTYPE HTML-WPS Office

The document contains an HTML registration form for users to input their personal information, including first name, last name, ID number, email, phone, age, department, and gender. It also includes PHP code for handling the form submission, connecting to a MySQL database, and inserting the data into a 'users' table. Additionally, there is a SQL statement to create the 'data' table with relevant fields.

Uploaded by

chak.m.beyena
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views6 pages

DOCTYPE HTML-WPS Office

The document contains an HTML registration form for users to input their personal information, including first name, last name, ID number, email, phone, age, department, and gender. It also includes PHP code for handling the form submission, connecting to a MySQL database, and inserting the data into a 'users' table. Additionally, there is a SQL statement to create the 'data' table with relevant fields.

Uploaded by

chak.m.beyena
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

<!

DOCTYPE html>

<html>

<head>

<title>Registration Form</title>

<style>

body {

font-family: Arial, sans-serif;

background-color: sky;

form {

width: 400px;

margin: 2 auto;

padding: 20px;

border: 1px solid #cc;

border-radius: 5px;

background-color: #fff;

label {

display: block;

margin-bottom: 10px;

input[type="text"],
input[type="email"],

input[type="password"]

width: 100%;

padding: 10px;

margin-bottom: 10px;

border: 1px solid #ccc;

border-radius: 5px;

input[type="submit"] { background-color: orange;

color: white;

padding: 10px 20px;

border: none;

border-radius: 5px;

cursor: pointer;

</style>

</head>

<body>

<form action="register.php" method="post">

<h2>Registration Form</h2>

<h3>MIS group 4</h3>

<label for="name">first_ame:</label>

<input type="text" id="name" name="first_name" required>


<label for="email">last_name:</label>

<input type="text" id="last_name" name="last_name" required>

<label for="Id_no">Id_no:</label>

<input type="text" id="Id_no" name="Id_no" required>

<label for="email">Email:</label>

<input type="email" id="email" name="email" required>

<label for="Phone">Phone:</label>

<input type="text" id="Phone" name="phone" required>

<label for="Age">Age:</label>

<input type="text" id="email" name="Age" required>

<label for="department">department:</label>

<input type="text" id="department" name="department" required>

<br>

Select Your Sex:

<input type="radio" name="gender" value="male" >Male

<input type="radio" name="gender" value="female">Female<br><br>

<input type="submit" value="Register">

</form>

</body>

</html>
<?php

// Database connection details

$servername = "your_servername";

$username = "your_username";

$password = "your_password";

$dbname = "mis";

// Create connection

$conn = new mysqli($servername, $username, $password, $dbname);

// Check connection

if ($conn->connect_error) {

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

// Retrieve form data

$first_name = $_POST['first_name'];

$last_name = $_POST['last_name'];

$id_no = $_POST['id_no'];

$email = $_POST['email'];

$phone = $_POST['phone'];

$age = $_POST['age'];

$department = $_POST['department'];
$age = $_POST['sex'];

// Prepare and execute the SQL statement

$sql = "INSERT INTO users (first_name, last_name, id_no, email, phone, age, department,sex) VALUES (?,
?, ?, ?, ?, ?, ?, ?)";

$stmt = $conn->prepare($sql);

$stmt->bind_param("sssssi", $first_name, $last_name, $id_no, $email, $phone, $age, $department);

if ($stmt->execute()) {

echo "Registration successful!";

} else {

echo "Error: " . $stmt->error;

$stmt->close();

$conn->close();

?>

CREATE TABLE data (

id INT AUTO_INCREMENT PRIMARY KEY,

first_name VARCHAR(50),

last_name VARCHAR(50),
id_no VARCHAR(20),

email VARCHAR(100),

phone VARCHAR(20),

department VARCHAR(30),

age INT,

sex VARCHAR(6)

);

You might also like