Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //database
- //loginpagina
- //backend
- //Inlog pagina
- //sql database maken
- //tabellen aanmaken
- //ingloggegevens
- //verbinding met database maken
- //aanmelden in systeem
- //systeem opbouwen
- // set variables
- if (isset($_POST['submit'])) {
- echo 'Het is verstuurd ';
- if (!empty($_POST['username'])) {
- echo $_POST['username'];
- } else {
- echo 'Vul een gebruikersnaam in!';
- }
- if (!empty($_POST['password'])) {
- echo $_POST['password'];
- } else {
- echo 'Vul een wachtwoord';
- }
- $dbhost = 'localhost:3306';
- $dbuser = 'admin';
- $dbpass = 'hello';
- $dbname = 'project';
- $conn = mysqli_connect($dbhost, $dbuser, $dbpass,$dbname);
- if(! $conn ) {
- die('Could not connect: ' . mysqli_error());
- }
- echo 'Connected successfully';
- $sql = "CREATE TABLE credentials (
- id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
- username VARCHAR(30) NOT NULL,
- password VARCHAR(30) NOT NULL,
- reg_date TIMESTAMP
- )";
- if ($conn->query($sql) === TRUE) {
- echo "New record created successfully";
- } else {
- echo "Error: " . $sql . "<br>" . $conn->error;
- }
- // attempt insert query execution
- $sql = "INSERT INTO persons (username, password) VALUES ('$username', '$password')";
- if(mysqli_query($link, $sql)){
- echo "Records added successfully.";
- } else{
- echo "ERROR: Could not able to execute $sql. " . mysqli_error($link);
- mysqli_close($conn);
- // If result matched $myusername and $mypassword, table row must be 1 row
- /* @var $count type */
- }
- ?>
- <html>
- <head>
- <title>Inlog</title>
- </head>
- <body>
- <form id="login" action="" method="post" accept-charset="UTF-8"
- <label for="username">Username:</label>
- <input type="text" name="username" id="username" maxlength="50" required />
- <br>
- <label for="Password">Password:</label>
- <input type="password" name="password" id="password" maxlength="50" required/>
- <br>
- <input type="submit" name="submit" value="Submit" />
- </form>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement