Jump to content

LeonLatex

Members
  • Posts

    393
  • Joined

  • Last visited

  • Days Won

    1

LeonLatex last won the day on May 29 2022

LeonLatex had the most liked content!

About LeonLatex

  • Birthday 01/04/1972

Profile Information

  • Gender
    Male
  • Location
    Norway
  • Interests
    electronics, hi-tech, computer and IT related things like database systems, programming, cars, boats, traveling, exploring and so much more. I think it's better you ask me what I am not interested in. It's easier to answer that question.
  • Age
    51
  • Donation Link

Contact Methods

  • Skype
    leon_latex

Recent Profile Visitors

40,776 profile views

LeonLatex's Achievements

Advanced Member

Advanced Member (4/5)

13

Reputation

2

Community Answers

  1. @maxxd@Strider64 Of course, I do. I don't save a plain-text password in the database Have you read through the thread, you would see that your question is so unnecessary, or am I wrong? The password is saved to the "password_hash" column in db, and id hashed with this: <?php $password = '******'; // Replace the stars with the actual password $hashed_password = password_hash($password, PASSWORD_DEFAULT); echo $hashed_password; // This will output the hashed version of the password for you. Just copy and paste ?>
  2. @mac_gyver, If you look in bottom of my first posting you find my login form. I dont have a registration form yet because so early in the development process i manually put the testing user accounts in mysql manually. I dont have time to use more time on this now, so i will start develop another system, and this time with email confirmation and a confirmation code. Is less use of time to put a new one together than looking for errors in this login system. I dont think there is only one error. The system has going through many changes through the last year, so it's time to let the old one rest. Any way, thanks for using time for trying to help 😃
  3. One of the first things I did was go through the password and username. I checked the db-connection with this one too: <?php $servername = "***.****.********.no"; $username = "*****_*****"; $password = "************"; $database = "*****_*****"; try { $pdo = new PDO("mysql:host=$servername;dbname=$database", $username, $password); $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); echo "Connection successful!"; } catch(PDOException $e) { echo "Error connecting: " . $e->getMessage(); } ?> Then I checked if the hashed password was corect and matched. As a precaution, I set up a new hashed password string using this code, and paste it into the database table users: <?php $password = '******'; // Replace this with the actual password $hashed_password = password_hash($password, PASSWORD_DEFAULT); echo $hashed_password; // This will output the hashed version of the password ?>
  4. Sorry again. There's a little busy here today (every day). The problem is that i get the $error_message = "Feil e-postadresse eller passord."; ...and I dont know why. It has been running fine on another site, but not on this site I am dealing with now. The only difference is the database. I cant find any there. Can you ?
  5. Of course Requinix. Here is that part: <?php // Inkluder skriptet for databasekobling. include_once $_SERVER['DOCUMENT_ROOT'] . '/includes/db.php'; if ($_SERVER['REQUEST_METHOD'] === 'POST') { // Hent brukerregistreringsdata fra skjemaet. $first_name = $_POST['first_name']; $last_name = $_POST['last_name']; $email = $_POST['email']; $password = $_POST['password']; // Dette skal være passordet i klartekst som brukeren oppgir. // Hash brukerens passord før det lagres i databasen. $hashed_password = password_hash($password, PASSWORD_DEFAULT); // SQL-spørring for å sette inn brukeren i databasen. $sql = "INSERT INTO users (first_name, last_name, email, password_hash) VALUES (:first_name, :last_name, :email, :password_hash)"; // Forbered og utfør SQL-setningen. $stmt = $pdo->prepare($sql); $stmt->bindParam(':first_name', $first_name); $stmt->bindParam(':last_name', $last_name); $stmt->bindParam(':email', $email); $stmt->bindParam(':password_hash', $hashed_password); if ($stmt->execute()) { // Brukerregistrering vellykket. echo "Bruker registrert vellykket!"; // Du kan omdirigere brukeren til en påloggingsside eller vise en suksessmelding. } else { // Brukerregistrering mislyktes. echo "Brukerregistrering mislyktes. Prøv igjen senere."; } } ?>
  6. I was setting up a login system that was working till I want it to hash the password. I paste both my user table in the database and login.php. I can't find what's wrong, can you? <?php // Inkluder databasekobling og nødvendige funksjoner include_once $_SERVER['DOCUMENT_ROOT'] . '/includes/db.php'; if ($_SERVER['REQUEST_METHOD'] === 'POST') { // Håndter innloggingsskjemaet som er sendt inn. $email = $_POST['email']; $password = $_POST['password']; // Hent brukerens hashed passord fra databasen basert på e-postadressen $sql = "SELECT * FROM users WHERE email = :email"; $stmt = $pdo->prepare($sql); $stmt->bindParam(':email', $email); $stmt->execute(); $user = $stmt->fetch(); if ($user && password_verify($password, $user['password_hash'])) { // Passordet er gyldig, opprett en brukersesjon session_start(); $_SESSION['user_id'] = $user['user_id']; $_SESSION['user_role'] = $user['role']; // Gi tilbakemelding til brukeren om vellykket innlogging header('Location: dashboard.php'); // Omdiriger til en beskyttet side exit(); } else { // Feil passord, gi tilbakemelding om innloggingsfeil $error_message = "Feil e-postadresse eller passord."; } } ?> <!DOCTYPE html> <html lang="en"> <head> <!-- ... Legg til nødvendige meta-informasjon og stiler ... --> </head> <body> <h2>Logg inn</h2> <?php if (isset($error_message)): ?> <p><?php echo $error_message; ?></p> <?php endif; ?> <form method="post" action="login.php"> <label for="email">E-postadresse:</label> <input type="email" id="email" name="email" required> <label for="password">Passord:</label> <input type="password" id="password" name="password" required> <input type="submit" value="Logg inn"> </form> </body> </html> /* Navicat MySQL Data Transfer SET NAMES utf8mb4; SET FOREIGN_KEY_CHECKS = 0; -- ---------------------------- -- Table structure for users -- ---------------------------- DROP TABLE IF EXISTS `users`; CREATE TABLE `users` ( `user_id` int(11) NOT NULL AUTO_INCREMENT, `first_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL, `middle_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL, `last_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL, `address` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL, `city` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL, `postal_code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL, `birthday` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL, `country` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL, `county` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL, `municipality` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL, `phone` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL, `sex` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL, `email` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL, `display_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL, `password_hash` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL, `confirm_password` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL, `confirm_code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL, `role` enum('user','moderator','administrator') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'user', `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`user_id`) USING BTREE ) ENGINE = InnoDB AUTO_INCREMENT = 17 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC; -- ---------------------------- -- Records of users -- ---------------------------- SET FOREIGN_KEY_CHECKS = 1;
  7. requinix, the problem is that the username/email does not match the specified size in the CSS document. The password field does, but not the username field. I know that this is probably a trivial issue, but I can't seem to spot the triviality. There might be an extra letter or one missing altogether.
  8. I am working on a new project, and I have a problem with CSS and the size of a text box for username/email. I want the box to change size like the password box, because that one works, but not the box for username/email. I am pasting the HTML and CSS below. Thank you for all your help. <form method="POST" action="login_process.php"> <div class="login_div"> <input type="text" name="email" placeholder="Email" required> <input type="password" name="password" placeholder="Passord" required> <label for="showPassword">Vis passord</label><input type="checkbox" id="showPassword"><p> <button type="submit">Login</button> </div> </form> <script> document.getElementById("showPassword").addEventListener("change", function () { var passwordInput = document.querySelector("input[name='password']"); if (passwordInput.type === "password") { passwordInput.type = "text"; } else { passwordInput.type = "password"; } }); </script> /* CSS Document */ /* styles.css */ body { font-family: Arial, sans-serif; background-color: #ffffff; margin: 0; padding: 0; } h2 { color: #333; } form { width: 300px; margin: 0 auto; padding: 20px; background-color: #fff; border-radius: 5px; box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1); } label { display: block; margin-bottom: 5px; font-size: 11px; font-weight: normal; } input[type="email"], input[type="password"] { width: 30%; padding: 2px; margin-bottom: 0px; border-radius: 5px solid thin #000; font-size: 14px; } input[type="submit"] { display: block; width: 10%; padding: 10px; background-color: #333; color: #fff; border:thin; border-radius: 5px; font-size: 14px; cursor: pointer; } input[type="submit"]:hover { background-color: #fff; }
  9. No, but I fixed it now. I set the charset to utf8mb4. Thanks Barand.
  10. Barand, i cant make it work wit Æ, Ø or Å. They won't save to the database. All other letters is saved in the database. Is the problem in the hashing of the password?
  11. I have set up this block for validating password reg. // Validering av passord if (strlen($password) < 8 || !preg_match("/[A-Z]/", $password) || !preg_match("/[0-9]/", $password)) { $error_message = "Passordet må være minst 8 tegn langt, inneholde minst én stor bokstav og ett tall."; // Legg til en feilmelding i en feilmeldingsarray for å vise senere. In can't make it work with Scandinavian special letters Ææ, Øø, Åå Does someone here know how to fix this?
  12. I am trying to follow this guide on how to configure GitHub Copilot in Visual Studio Code. That goes well till I come to number three. Where is that login button in the left corner? How does it look? -------------------- To configure Github Copilot in Visual Studio Code, you need to follow these steps: 1- Install Visual Studio Code: If you haven't already, you can download and install Visual Studio Code from the official website: https://code.visualstudio.com/. 2- Install the Github Copilot extension: Open Visual Studio Code and click on the "Extensions" icon in the left-hand sidebar. Search for "Github Copilot" and install the official extension that is developed by Github and Microsoft. 3- Sign in to Github: After installing the extension, click on the "Sign in to GitHub" button in the bottom left corner of the Visual Studio Code window, and follow the instructions to sign in to your Github account. 4- Activate Github Copilot: Once you are signed in to Github, you can activate Github Copilot by opening a file and typing some code. Press "Ctrl+Space" (Windows, Linux) or "Cmd+Space" (Mac) to trigger Github Copilot, and it will start suggesting code for you. 5- Customize the settings: You can customize the settings for Github Copilot by going to the Visual Studio Code settings (File > Preferences > Settings), searching for "Github Copilot", and adjusting the relevant settings to your preference. 6- That's it! You should now be able to use Github Copilot in Visual Studio Code. Just remember that Github Copilot is an AI-powered code generator that uses machine learning to suggest code based on context, and it is not a complete replacement for manual coding. You should always review and understand the code generated by Github Copilot before using it in production environments.
  13. I have asked about this in another project before, but now the problem is back. I am still struggling with this. Read through my CSS, and look at my HTML, I can't understand this no matter how hard I try, over and over again. My screen resolution is 1920X1080. In that resolution, the site looks as I want. It's only the header and the menu bar whos not cooperating. For those of you who want to see this problem in action and, what's happening and what's not happening, here is the link to the site: www.matsnakk.com This is the one who's making all the trouble, but i need it for scaling my header banner background image: background: url("../../images/matsnakk_header.png") no-repeat; background-size: contain; /*Makes the background scaling.*/ <?php error_reporting(E_ALL); ini_set('display_errors', 1); include $_SERVER['DOCUMENT_ROOT'] . '/includes/db.php'; ?> <!doctype html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title><?php echo $article['title_tag']; ?></title> <link rel='stylesheet' href='https://www.w3schools.com/w3css/4/w3.css'> <link rel="stylesheet" href="<?php echo BASE_URL; ?>scripts/css/style.css" rel="stylesheet" type="text/css"> <link rel="stylesheet" href="<?php echo BASE_URL; ?>scripts/css/navbar.css" rel="stylesheet" type="text/css"> <link rel="stylesheet" href="<?php echo BASE_URL; ?>scripts/css/header.css" rel="stylesheet" type="text/css"> <link rel="stylesheet" href="<?php echo BASE_URL; ?>scripts/css/main.css" rel="stylesheet" type="text/css"> <link rel="stylesheet" href="<?php echo BASE_URL; ?>scripts/css/footer.css" rel="stylesheet" type="text/css"> <link rel="stylesheet" href="<?php echo BASE_URL; ?>scripts/css/main_elements.css" rel="stylesheet" type="text/css"> </head> <body class="body"> <div class="banner"></div> <div class="menu_div"> <a href='<?=$HOST?>index.php'class='w3-bar-item w3-button color: white w3-round-tiny w3-hover-white'>Hjem</a> <a href='<?=$HOST?>recipes.php'class='w3-bar-item w3-button w3-round-tiny w3-hover-white'>Oppskrifter</a> <a href='<?=$HOST?>restaurants.php'class='w3-bar-item w3-button w3-round-tiny w3-hover-white'>Restauranter</a> <a href='<?=$HOST?>recipes.php'class='w3-bar-item w3-button w3-round-tiny w3-hover-white'>Café - Diners</a> <a href='<?=$HOST?>roadside.php'class='w3-bar-item w3-button w3-round-tiny w3-hover-white'>Etter veien</a> <a href='<?=$HOST?>fastfood.php'class='w3-bar-item w3-button w3-round-tiny w3-hover-white'>Fastfood</a> <a href='<?=$HOST?>forums.php'class='w3-bar-item w3-button w3-round-tiny w3-hover-white'>Diskuter</a> <a href='<?=$HOST?>news.php'class='w3-bar-item w3-button w3-round-tiny w3-hover-white'>Nyheter</a> <a href='<?=$HOST?>about.php'class='w3-bar-item w3-button w3-round-tiny w3-hover-white'>Om Matsnakk</a> </div></div> <div class="main_bg"> </div> <div class="footer_bg"> <br> <div class="footer"> Matsnakk &copy;<br> All Rights Reserved. </div> </footer> </body> </html> /* CSS Document */ div.logo_bg { width: 250px; height: 69px; margin-left: 28px; margin-top: 0px; margin-bottom: 0px; margin-right: 0px; padding-top: 0px; padding-left: 10px; } div.container { background-color: #f7f7f7; display: flex; position: fixed; box-sizing: border-box; overflow: hidden; height: 100%; width: 100%; top: 0px; left: 0px; } body.style { background-color: #f7f7f7; font-family: "Verdana, Consolas", "Lucida Grande", "Lucida Sans Unicode", "Lucida Sans", "DejaVu Sans", "sans-serif"; padding-top: 0PX; margin-top: 0px; } div.banner { background-color: #033333; background: url("../../images/matsnakk_header.png") no-repeat; background-size: contain; /*Makes the background scaling.*/ width: 100%; height: 250px; position: fixed; } /*div.logo_div { background-image: url("../../images/matsnakk_logo_liten.png"); flex: 1; position: fixed; box-sizing: border-box; height: 69px; width: 250px; top: 11px; left: 30px; }*/ div.menu_bar { background-color: #033333; position: fixed; box-sizing: border-box; overflow: hidden; font-size: 15px; font-weight: bold; margin-top: 0px; height: 25px; width: 100%; top: 0px; left: 0px; } div.menu_div { display: flex; justify-content: center; margin-top: 10px; background-color: #f7f7f7; position: fixed; box-sizing: border-box; overflow: hidden; height: 35px; width: 100%; top: 240px; left: 0px; border-bottom: 2px solid #033333; }
  14. I can't figure this puzzle out. I have tried most things throughout the night, but I have not set up this DIV as either a FLEX CONTAINER or a GRID CONTAINER. So, I tried to do that too, but it wasn't working. Do I have to place it in some special place in the CSS code? So, what will work here to align the text and content in this menu bar in center position? Everything is on one line too. I would appreciate it if someone could show me where to put it? <body class="body"> <div class="menu_div">Menu items</div> div.menu_div { margin-top: 10px; background-color: #ffffff; position: fixed; box-sizing: border-box; overflow: hidden; height: 35px; width: 100%; top: 83px; left: 0px; border-bottom: thin solid #033333; }
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.