Advertisement
Guest User

Untitled

a guest
May 17th, 2018
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.27 KB | None | 0 0
  1. <?php
  2.     //database
  3.     //loginpagina
  4.     //backend
  5.  
  6.     //Inlog pagina
  7.     //sql database maken
  8.     //tabellen aanmaken
  9.     //ingloggegevens
  10.     //verbinding met database maken
  11.     //aanmelden in systeem
  12.  
  13.     //systeem opbouwen
  14. // set variables
  15.  
  16.  
  17. if (isset($_POST['submit'])) {
  18.         echo 'Het is verstuurd ';
  19.         if (!empty($_POST['username'])) {
  20.             echo $_POST['username'];
  21.         }  else {
  22.                echo 'Vul een gebruikersnaam in!';
  23.         }
  24.         if (!empty($_POST['password'])) {
  25.             echo $_POST['password'];
  26.         }  else {
  27.                echo 'Vul een wachtwoord';
  28.         }
  29.    
  30.    $dbhost = 'localhost:3306';
  31.    $dbuser = 'admin';
  32.    $dbpass = 'hello';
  33.    $dbname = 'project';
  34.    
  35.    $conn = mysqli_connect($dbhost, $dbuser, $dbpass,$dbname);
  36.    
  37.    if(! $conn ) {
  38.       die('Could not connect: ' . mysqli_error());
  39.    }
  40.      
  41.    echo 'Connected successfully';
  42.    
  43.    
  44. $sql = "CREATE TABLE credentials (
  45. id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
  46. username VARCHAR(30) NOT NULL,
  47. password VARCHAR(30) NOT NULL,
  48. reg_date TIMESTAMP
  49. )";
  50.  
  51. if ($conn->query($sql) === TRUE) {
  52.     echo "New record created successfully";
  53. } else {
  54.     echo "Error: " . $sql . "<br>" . $conn->error;
  55. }
  56.  
  57.  
  58. // attempt insert query execution
  59. $sql = "INSERT INTO persons (username, password) VALUES ('$username', '$password')";
  60. if(mysqli_query($link, $sql)){
  61.     echo "Records added successfully.";
  62. } else{
  63.     echo "ERROR: Could not able to execute $sql. " . mysqli_error($link);
  64.    
  65.    mysqli_close($conn);
  66.    
  67.  
  68.  
  69.  
  70.      
  71.       // If result matched $myusername and $mypassword, table row must be 1 row
  72.        
  73. /* @var $count type */
  74. }
  75.    
  76.  
  77. ?>
  78.  
  79. <html>
  80.     <head>
  81.         <title>Inlog</title>
  82.     </head>
  83.  
  84.     <body>
  85.         <form id="login" action="" method="post" accept-charset="UTF-8"
  86.             <label for="username">Username:</label>
  87.             <input type="text" name="username" id="username" maxlength="50" required />
  88.             <br>
  89.             <label for="Password">Password:</label>
  90.             <input type="password" name="password" id="password" maxlength="50" required/>
  91.             <br>
  92.             <input type="submit" name="submit" value="Submit" />
  93.         </form>
  94.     </body>
  95.  
  96.  
  97. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement