Advertisement
PadmaJS

Untitled

Mar 30th, 2024
1,166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Erlang 8.19 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4.   <title>Registration form</title>
  5.   <meta charset="utf-8">
  6.   <meta name="viewport" content="width=device-width, initial-scale=1">
  7.   <link rel="stylesheet" href="css/style.css">
  8.   <?php include "links.php" ?>
  9. </head>
  10. <body?>
  11. <div class="container register">
  12.     <div class="row">
  13.         <div class="col-md-3 register-left">
  14.             <h3>Welcome</h3>
  15.             <p>Travelling – it leaves you speechless, then turns you into a storyteller</p>
  16.             <input type="submit" value="Login"/><br/>
  17.         </div>
  18.         <div class="col-md-9 register-right">
  19.             <ul class="nav nav-tabs nav-justified" id="myTab" role="tablist">
  20.                 <li class="nav-item">
  21.                     <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>
  22.                 </li>
  23.                 <li class="nav-item">
  24.                     <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>
  25.                 </li>
  26.             </ul>
  27.             <div class="tab-content" id="myTabContent">
  28.                 <div class="tab-pane fade show active" id="home" role="tabpanel" aria-labelledby="home-tab">
  29.                     <h3 class="register-heading">Form for Guide</h3>
  30.                     <form action="" method="POST">
  31.                         <div class="row register-form">
  32.                             <div class="col-md-6">
  33.                                 <div class="form-group">
  34.                                     <input type="text" name="firstName" class="form-control" placeholder="First Name *" value="" />
  35.                                 </div>
  36.                                 <div class="form-group">
  37.                                     <input type="text" name="lastName" class="form-control" placeholder="Last Name *" value="" />
  38.                                 </div>
  39.                                 <div class="form-group">
  40.                                     <input type="email" name="email" class="form-control" placeholder="Your Email *" value="" />
  41.                                 </div>
  42.                                 <div class="form-group">
  43.                                     <input type="password" name="password" class="form-control" placeholder="Password *" value="" />
  44.                                 </div>
  45.                                
  46.                             </div>
  47.                             <div class="col-md-6">
  48.                                 <div class="form-group">
  49.                                     <input type="text" name="phonenumber" minlength="10" maxlength="10" class="form-control" placeholder="Your Phone *" value="" />
  50.                                 </div>
  51.                                 <div class="form-group">
  52.                                 <input type="text" name="qualification" class="form-control" placeholder="Your Qualification *" value="" required />
  53.                             </div>
  54.                             <div class="form-group">
  55.                                 <input type="text" name="experience" class="form-control" placeholder="Your experience *" value="" required />
  56.                             </div>
  57.                                 <input type="submit" name="submit_guide" class="btnRegister" value="Register"/>
  58.                             </div>
  59.                         </div>
  60.                     </form>
  61.                 </div>
  62.                 <div class="tab-pane fade show" id="profile" role="tabpanel" aria-labelledby="profile-tab">
  63.                     <h3 class="register-heading">Form for client</h3>
  64.                     <form action="" method="POST">
  65.                         <div class="row register-form">
  66.                             <div class="col-md-6">
  67.                                 <div class="form-group">
  68.                                     <input type="text" name="first_name" class="form-control" placeholder="First Name *" value="" />
  69.                                 </div>
  70.                                 <div class="form-group">
  71.                                     <input type="text" name="last_name" class="form-control" placeholder="Last Name *" value="" />
  72.                                 </div>
  73.                                 <div class="form-group">
  74.                                     <input type="email" name="email" class="form-control" placeholder="Email *" value="" />
  75.                                 </div>
  76.                                
  77.                             </div>
  78.                             <div class="col-md-6">
  79.                                 <div class="form-group">
  80.                                 <div class="form-group">
  81.                                     <input type="text" name="phone_number" maxlength="10" minlength="10" class="form-control" placeholder="Phone *" value="" />
  82.                                 </div>
  83.                                     <input type="password" name="password" class="form-control" placeholder="Password *" value="" />
  84.                                 </div>
  85.                                 <input type="hidden" name="user_type" id="user_type" value="" />
  86.                                 <input type="submit" name="submit_client" class="btnRegister" value="Register"/>
  87.                             </div>
  88.                         </div>
  89.                     </form>
  90.                 </div>
  91.             </div>
  92.         </div>
  93.     </div>
  94. </div>
  95. </body>
  96. </html>
  97. <script>
  98.   function setUserType(type) {
  99. document.getElementById('user_type').value = type;
  100. }
  101.  </script>
  102. <?php
  103.  
  104. $servername = "localhost";
  105. $username = "root";
  106. $password = "";
  107. $dbname = "contact";
  108. $conn = new mysqli($servername, $username, $password, $dbname);
  109. if ($conn->connect_error) {
  110.     die("Connection failed: " . $conn->connect_error);
  111. }
  112.  
  113.  
  114. if(isset($_POST['submit_client']) && isset($_POST['first_name'])) {
  115.     $first_name = $_POST["first_name"];
  116.     $last_name = $_POST["last_name"];
  117.     $email = $_POST['email'];
  118.     $phone_number = $_POST['phone_number'];
  119.     $password = $_POST['password'];
  120.    
  121.     // Insert data into the register table for clients
  122.     $insertquery = "INSERT INTO register (first_name, last_name, email, phone_number, password)
  123.                    VALUES (?, ?, ?, ?, ?)";
  124.     $stmt = mysqli_prepare($conn, $insertquery);
  125.     mysqli_stmt_bind_param($stmt, "sssss", $first_name, $last_name, $email, $phone_number, $password);
  126.     if(mysqli_stmt_execute($stmt)){
  127.         echo '<script>alert("Client data inserted properly");</scrip>';
  128.     } else {
  129.         echo '<script>alert("Client data not inserted: ' . mysqli_error($conn) . '");</script>';
  130.     }
  131.     mysqli_stmt_close($stmt);
  132. }
  133.  
  134. if(isset($_POST['submit_guide']) && isset($_POST['firstName'])) {
  135.     $firstName = $_POST["firstName"];
  136.     $lastName = $_POST["lastName"];
  137.     $email = $_POST['email'];
  138.     $password = $_POST['password'];
  139.     $phonenumber = $_POST['phonenumber'];
  140.     $qualification = $_POST['qualification'];
  141.     $experience = $_POST['experience'];
  142.    
  143.     // Insert data into the register_guide table for guides
  144.     $insertquery = "INSERT INTO `register_guide` (firstName, lastName, email, password, phonenumber, qualification,experience)
  145.                    VALUES (?, ?, ?, ?, ?, ?, ?)";
  146.     $stmt = mysqli_prepare($conn, $insertquery);
  147.     mysqli_stmt_bind_param($stmt, "sssssss", $firstName, $lastName, $email, $password, $phonenumber,  $qualification, $experience);
  148.     if(mysqli_stmt_execute($stmt)){
  149.        // echo '<script>alert("Guide data inserted properly");</script>';
  150.     } else {
  151.         echo '<script>("Guide data not inserted: ' . mysqli_error($conn) . '");</script>';
  152.        
  153.     }
  154.     mysqli_stmt_close($stmt);
  155. }
  156.  
  157. $conn->close();
  158.  
  159. /*$sql = "INSERT INTO register_guide (first_name, last_name, email, password, phone_number, qualification, experience)
  160.        VALUES ('$firstName', '$lastName', '$email', '$password', '$phonenumber', '$qualification', '$experience')";
  161.  
  162. if ($conn->query($sql) === TRUE) {
  163.     echo "New record inserted successfully!";
  164. } else {
  165.     echo "Error: " . $sql . "<br>" . $conn->error;
  166. }
  167. }*/
  168. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement