fork download
  1. <?php
  2. $insert = false;
  3.  
  4. if (isset($_POST['name'])) {
  5. $server = "localhost";
  6. $username = "root";
  7. $password = "";
  8.  
  9. $con = mysqli_connect($server, $username, $password);
  10.  
  11. if (!$con) {
  12. die("Connection to this database failed due to " . mysqli_connect_error());
  13. }
  14.  
  15. // echo "success connecting to the db";
  16.  
  17. $name = $_POST['name'];
  18. $gender = $_POST['gender'];
  19. $age = $_POST['age'];
  20. $email = $_POST['email'];
  21. $phone = $_POST['phone'];
  22. $desc = $_POST['desc'];
  23.  
  24. $sql = "INSERT INTO `trip`. `trip` (`name`, `age`, `gender`, `email`, `phone`, `desc`, `dt`) VALUES ('$name', '$age', '$gender', '$email', '$phone', '$desc', current_timestamp());";
  25.  
  26. // echo $sql;
  27.  
  28. if ($con->query($sql) === true) {
  29. // echo "successfully inserted";
  30. $insert = true;
  31. } else {
  32. echo "Error: $sql <br> $con->error";
  33. }
  34.  
  35. $con->close();
  36. }
  37. ?>
  38.  
  39. <!DOCTYPE html>
  40. <html lang="en">
  41. <head>
  42. <meta charset="UTF-8">
  43. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  44. <title>Travel Us Trip</title>
  45.  
  46. <link rel="preconnect" href="https://f...content-available-to-author-only...s.com">
  47. <link rel="preconnect" href="https://f...content-available-to-author-only...c.com" crossorigin>
  48. <link href="https://f...content-available-to-author-only...s.com/css2?family=Rubik+Wet+Paint&display=swap" rel="stylesheet">
  49. <link rel="stylesheet" href="style.css">
  50. </head>
  51. <body>
  52. <img class="bg" src="bg.png" alt="iiit">
  53. <div class="container">
  54. <h1>Travel for Us Trip Form</h1>
  55. <p>Hi, we are ready to go to the US!</p>
  56.  
  57. <?php
  58. if ($insert == true) {
  59. echo "<p class='submitmsg'>Thanks for submitting your form. We are happy to see you.</p>";
  60. }
  61. ?>
  62.  
  63. <form action="index.php" method="post">
  64. <input type="text" name="name" id="name" placeholder="Enter your name">
  65. <input type="text" name="age" id="age" placeholder="Enter your age">
  66. <input type="email" name="email" id="email" placeholder="Enter your email">
  67. <input type="phone" name="phone" id="phone" placeholder="Enter your phone">
  68. <textarea name="desc" id="desc" cols="30" rows="10" placeholder="Enter description of your trip"></textarea>
  69. <button class="btn">Submit</button>
  70. </form>
  71. </div>
  72.  
  73. <script src="index.js"></script>
  74. </body>
  75. </html>
  76.  
Success #stdin #stdout 0.04s 25984KB
stdin
Standard input is empty
stdout
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Travel Us Trip</title>

    <link rel="preconnect" href="https://f...content-available-to-author-only...s.com">
    <link rel="preconnect" href="https://f...content-available-to-author-only...c.com" crossorigin>
    <link href="https://f...content-available-to-author-only...s.com/css2?family=Rubik+Wet+Paint&display=swap" rel="stylesheet">
    <link rel="stylesheet" href="style.css">
</head>
<body>
    <img class="bg" src="bg.png" alt="iiit">
    <div class="container">
        <h1>Travel for Us Trip Form</h1>
        <p>Hi, we are ready to go to the US!</p>

        
        <form action="index.php" method="post">
            <input type="text" name="name" id="name" placeholder="Enter your name">
            <input type="text" name="age" id="age" placeholder="Enter your age">
            <input type="email" name="email" id="email" placeholder="Enter your email">
            <input type="phone" name="phone" id="phone" placeholder="Enter your phone">
            <textarea name="desc" id="desc" cols="30" rows="10" placeholder="Enter description of your trip"></textarea>
            <button class="btn">Submit</button>
        </form>
    </div>

    <script src="index.js"></script>
</body>
</html>