Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <title>Registration form</title>
- <meta charset="utf-8">
- <meta name="viewport" content="width=device-width, initial-scale=1">
- <link rel="stylesheet" href="css/style.css">
- <?php include "links.php" ?>
- </head>
- <body?>
- <div class="container register">
- <div class="row">
- <div class="col-md-3 register-left">
- <h3>Welcome</h3>
- <p>Travelling – it leaves you speechless, then turns you into a storyteller</p>
- <input type="submit" value="Login"/><br/>
- </div>
- <div class="col-md-9 register-right">
- <ul class="nav nav-tabs nav-justified" id="myTab" role="tablist">
- <li class="nav-item">
- <a onclick="setUserType('guest')" class="nav-link active" id="home-tab" data-toggle="tab" href="#home" role="tab" aria-controls="home" aria-selected="true">Guide</a>
- </li>
- <li class="nav-item">
- <a onclick="setUserType('client')" class="nav-link" id="profile-tab" data-toggle="tab" href="#profile" role="tab" aria-controls="profile" aria-selected="false">Client</a>
- </li>
- </ul>
- <div class="tab-content" id="myTabContent">
- <div class="tab-pane fade show active" id="home" role="tabpanel" aria-labelledby="home-tab">
- <h3 class="register-heading">Form for Guide</h3>
- <form action="" method="POST">
- <div class="row register-form">
- <div class="col-md-6">
- <div class="form-group">
- <input type="text" name="firstName" class="form-control" placeholder="First Name *" value="" />
- </div>
- <div class="form-group">
- <input type="text" name="lastName" class="form-control" placeholder="Last Name *" value="" />
- </div>
- <div class="form-group">
- <input type="email" name="email" class="form-control" placeholder="Your Email *" value="" />
- </div>
- <div class="form-group">
- <input type="password" name="password" class="form-control" placeholder="Password *" value="" />
- </div>
- </div>
- <div class="col-md-6">
- <div class="form-group">
- <input type="text" name="phonenumber" minlength="10" maxlength="10" class="form-control" placeholder="Your Phone *" value="" />
- </div>
- <div class="form-group">
- <input type="text" name="qualification" class="form-control" placeholder="Your Qualification *" value="" required />
- </div>
- <div class="form-group">
- <input type="text" name="experience" class="form-control" placeholder="Your experience *" value="" required />
- </div>
- <input type="submit" name="submit_guide" class="btnRegister" value="Register"/>
- </div>
- </div>
- </form>
- </div>
- <div class="tab-pane fade show" id="profile" role="tabpanel" aria-labelledby="profile-tab">
- <h3 class="register-heading">Form for client</h3>
- <form action="" method="POST">
- <div class="row register-form">
- <div class="col-md-6">
- <div class="form-group">
- <input type="text" name="first_name" class="form-control" placeholder="First Name *" value="" />
- </div>
- <div class="form-group">
- <input type="text" name="last_name" class="form-control" placeholder="Last Name *" value="" />
- </div>
- <div class="form-group">
- <input type="email" name="email" class="form-control" placeholder="Email *" value="" />
- </div>
- </div>
- <div class="col-md-6">
- <div class="form-group">
- <div class="form-group">
- <input type="text" name="phone_number" maxlength="10" minlength="10" class="form-control" placeholder="Phone *" value="" />
- </div>
- <input type="password" name="password" class="form-control" placeholder="Password *" value="" />
- </div>
- <input type="hidden" name="user_type" id="user_type" value="" />
- <input type="submit" name="submit_client" class="btnRegister" value="Register"/>
- </div>
- </div>
- </form>
- </div>
- </div>
- </div>
- </div>
- </div>
- </body>
- </html>
- <script>
- function setUserType(type) {
- document.getElementById('user_type').value = type;
- }
- </script>
- <?php
- $servername = "localhost";
- $username = "root";
- $password = "";
- $dbname = "contact";
- $conn = new mysqli($servername, $username, $password, $dbname);
- if ($conn->connect_error) {
- die("Connection failed: " . $conn->connect_error);
- }
- if(isset($_POST['submit_client']) && isset($_POST['first_name'])) {
- $first_name = $_POST["first_name"];
- $last_name = $_POST["last_name"];
- $email = $_POST['email'];
- $phone_number = $_POST['phone_number'];
- $password = $_POST['password'];
- // Insert data into the register table for clients
- $insertquery = "INSERT INTO register (first_name, last_name, email, phone_number, password)
- VALUES (?, ?, ?, ?, ?)";
- $stmt = mysqli_prepare($conn, $insertquery);
- mysqli_stmt_bind_param($stmt, "sssss", $first_name, $last_name, $email, $phone_number, $password);
- if(mysqli_stmt_execute($stmt)){
- echo '<script>alert("Client data inserted properly");</scrip>';
- } else {
- echo '<script>alert("Client data not inserted: ' . mysqli_error($conn) . '");</script>';
- }
- mysqli_stmt_close($stmt);
- }
- if(isset($_POST['submit_guide']) && isset($_POST['firstName'])) {
- $firstName = $_POST["firstName"];
- $lastName = $_POST["lastName"];
- $email = $_POST['email'];
- $password = $_POST['password'];
- $phonenumber = $_POST['phonenumber'];
- $qualification = $_POST['qualification'];
- $experience = $_POST['experience'];
- // Insert data into the register_guide table for guides
- $insertquery = "INSERT INTO `register_guide` (firstName, lastName, email, password, phonenumber, qualification,experience)
- VALUES (?, ?, ?, ?, ?, ?, ?)";
- $stmt = mysqli_prepare($conn, $insertquery);
- mysqli_stmt_bind_param($stmt, "sssssss", $firstName, $lastName, $email, $password, $phonenumber, $qualification, $experience);
- if(mysqli_stmt_execute($stmt)){
- // echo '<script>alert("Guide data inserted properly");</script>';
- } else {
- echo '<script>("Guide data not inserted: ' . mysqli_error($conn) . '");</script>';
- }
- mysqli_stmt_close($stmt);
- }
- $conn->close();
- /*$sql = "INSERT INTO register_guide (first_name, last_name, email, password, phone_number, qualification, experience)
- VALUES ('$firstName', '$lastName', '$email', '$password', '$phonenumber', '$qualification', '$experience')";
- if ($conn->query($sql) === TRUE) {
- echo "New record inserted successfully!";
- } else {
- echo "Error: " . $sql . "<br>" . $conn->error;
- }
- }*/
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement