Jump to content

LeonLatex

Members
  • Posts

    396
  • 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

42,068 profile views

LeonLatex's Achievements

Advanced Member

Advanced Member (4/5)

13

Reputation

2

Community Answers

  1. Certainly! You can incorporate the admin link into your existing code by checking the user level after the login check. Here's how you might modify your code: Check the user level after confirming that the user is logged in. Display the admin link if the user level is 1. Provide an alternative link for other users. Here’s how you can integrate the admin link into your code: <?php include ("styles/top.php"); ?> <div id="left"> <img src="images/john.png" height="600px" width="300px" /> </div> <div id="right"> <div id="view_box"> <ul> <li><img src="images/1.png" /></li> <!-- <li><img src="pics/2.jpg" /></li> --> <!-- <li><img src="pics/3.jpg" /></li> --> </ul> </div> <div id="button"> <ul> <!-- <li><button class="button" scroll_value="0">*</button></li> --> <!-- <li><button class="button" scroll_value="600">*</button></li> --> <!-- <li><button class="button" scroll_value="1200">*</button></li> --> </ul> </div> <hr /> <?php if (loggedin()) { echo "<h3><font color='Yellow'>Welcome, {$customer_name}</font></h3>"; if ($user_level == 1) { echo "<a href='admin.php'>Admin Panel</a> | "; } else { echo "<a href='user_dashboard.php'>User Dashboard</a> | "; } echo "<h3>Money That Your Due Today</h3>"; echo '<table border="1"> <tr> <th>FULL NAME</th> <th>DATE GOT</th><th>MONEY DUE</th> <th>UPDATE</th> </tr>'; // Your existing code for fetching and displaying order data continues here... // (Insert your existing code for fetching data from the database and displaying it) echo '<tr> <td>&nbsp;</td> <td>TOTAL DUE</td> <td>&pound;' . number_format($totmoney, 2) . '&nbsp;</td> <td></td> </tr>'; echo '</table><br />'; } else { echo '<h3>Login To Your Account</h3>'; echo '<form method="post" action="login.php"> <table cellspacing="10" cellpadding="10"> <tr> <td>Username</td> <td><input type="text" name="username" /></td> </tr> <tr> <td>Password</td> <td><input type="password" name="password" /></td> </tr> <tr> <td></td> <td><input type="submit" name="submit" value="Login To Your Account" /></td> </tr> </table> </form>'; } ?> </div> <?php include ("styles/bottom.php"); ?> Explanation: User Level Check: After confirming the user is logged in, you check if $user_level is 1. If it is, you display the admin link. If not, you can display a different link (like a user dashboard link). Dynamic Links: This makes your application more dynamic, allowing you to cater different content based on user roles. Feel free to adjust the link destinations (admin.php, user_dashboard.php, etc.) to fit your application's structure!
  2. Requinix, i dont know if this a good solution or not. I don't understand what you mean with a tag system. Does it mean to mark some specific image, text, file or directory or something? Is this controlled by a config.php file?
  3. This is being planned, and will have it down on paper for the time being. Actually, the question is not how to set up the database's rows and columns, because I reckon that is the usual way to do it. If it isn't, shout it out. It's when it comes to inserting data, extracting data that it gets a bit confusing. This is a page that is supposed to be about food. E.g. dishes as a category. Or imagine dishes as a topic where there are different dishes such as from different countries. These must then be collected on the food dish from the country that is indicated where the food dish originates, etc., and there may be several subcategories. What is the best way to solve this? This is what I came up with so far. There will probably be more later. Just give me some time so I can get started. Since the last time, my body and I have been on quite a journey. In October 2023 I traveled to Thailand to be there until March 2024. In January 2024 I got food poisoning, and this meant that I was bedridden in the hotel for 2 months. Everything I ate and drank went down into my stomach and returned immediately. Obviously, this resulted in severe dehydration and nutrient absorption. This led to kidney failure and nerve damage throughout the body. I have been and am still seriously ill and am still in a wheelchair in a nursing home. My feet and legs as well as fingers are numb and my fingertips are numb and half numb. That's why I haven't programmed for almost half a year. I also haven't been here on the PHP Freaks forum in as long. As I said, I'm not quite well yet, but I'm getting better and better, and a nerve injury takes a long time to heal.
  4. @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 ?>
  5. @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 😃
  6. 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 ?>
  7. 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 ?
  8. 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."; } } ?>
  9. 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;
  10. 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.
  11. 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; }
  12. No, but I fixed it now. I set the charset to utf8mb4. Thanks Barand.
  13. 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?
  14. 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?
  15. 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.
×
×
  • 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.