Advertisement
Guest User

data.php

a guest
Oct 14th, 2021
288
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.87 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4.     <meta charset="UTF-8">
  5.     <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6.     <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7.     <title>Results</title>
  8. </head>
  9.  
  10.  
  11. <body>
  12.     <div id = "results"></div>
  13.     <a href = "/">Back to Form</a>
  14. </body>
  15.  
  16.  
  17. <?php
  18.  
  19. $host_name = '///////';
  20. $database = '///////';
  21. $user_name = '///////';
  22. $password = '////////';
  23.  
  24. $link = new mysqli($host_name, $user_name, $password, $database);
  25.  
  26. if ($link->connect_error) {
  27.   die('<p>Failed to connect to MySQL: '. $link->connect_error .'</p>');
  28. } else {
  29.   echo '<p>Connection to MySQL server successfully established.</p>';
  30. }
  31.  
  32.         $first_name =  $_REQUEST['firstName'];
  33.         $last_name = $_REQUEST['lastName'];
  34.         $email =  $_REQUEST['Email'];
  35.         $username = $_REQUEST['userName'];
  36.         $password = $_REQUEST['Password'];
  37.        
  38.         $sql = "CREATE TABLE info (
  39.            id INT(8) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
  40.            firstname VARCHAR(30) NOT NULL,
  41.            lastname VARCHAR(30) NOT NULL,
  42.            email VARCHAR(50),
  43.            username VARCHAR(30) NOT NULL,
  44.            pass VARCHAR(30) NOT NULL,
  45.            )";
  46.  
  47.         $insert = "INSERT INTO info  VALUES ('$first_name','$last_name','$email','$username','$password')";
  48.  
  49.         $selected = "SELECT * FROM info";
  50.         $result = $link->query($selected);
  51.        
  52.  
  53.         echo "<table>"; // start a table tag in the HTML
  54.  
  55.         while($row = $result->fetch_assoc()){   //Creates a loop to loop through results
  56.         echo "<tr><td>" . $row['id'] . "</td><td>" . $row['firstname'] . "</td><td>" . $row['lastname'] . "</td> <td>" . $row['email'] . "</td> <td>" . $row['username'] . "</td> <td>" . $row['pass'] . "</td></tr>";}
  57.  
  58.         echo "</table>"; //Close the table in HTML
  59.  
  60.            
  61.  
  62. ?>
  63. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement