-
Posts
399 -
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
LeonLatex's Achievements
-
Docker and Windows PowerShell config.
LeonLatex replied to LeonLatex's topic in Editor Help (PhpStorm, VS Code, etc)
Since no one here could answer me or come up with a solution, I had to use some time, that I didn't have too much of. So, I asked my AI friend POE so I could have a quick answer. It worked for me, so feel free... Here's the solution: WWW is the name of my directory where i save all mine and others web pages locally. (My question to the AI in bold first) ___________________________________________________________________________________________________________________________________________________________________________________________ The Git repository is related to Docker. My directory, named WWW, contains multiple and different websites that I need to keep. Since I have a backup of this, I can delete the content if I cannot add WWW with the content inside, but I need to be able to restore the backup after installation and configuration. Is this possible, and will Docker and Git work with multiple directories containing websites, or is it only applicable to one directory and one website at a time? Yes, you can use Docker and Git together with multiple directories and websites. Here are some things to consider: 1. Directory Organization: You can have multiple directories within a single Docker container or project. Each directory can contain different websites. For example, you could have a structure like this: /project ├── /WWW │ ├── /site1 │ ├── /site2 │ └── /site3 └── Dockerfile 2. Dockerfile and Multi-Stage Builds: You can use a Dockerfile to set up all of your websites. If each website requires specific dependencies, you can use multi-stage builds to handle them efficiently. 3. Docker Volumes: To preserve the contents of the WWW directory and make it easier to update, you can use Docker volumes. This allows changes in the directory on the host machine to be reflected in the Docker container: docker run -v /path/to/WWW:/usr/share/nginx/html -d nginx 4. Using Git with Multiple Directories: You can also use Git with multiple directories. If you have a Git repository with multiple projects, you can clone it into the WWW directory. Alternatively, you can have separate Git repositories for each website and clone them into their respective directories. 5. Backup of Directories: Since you have a backup of WWW, you can safely clear the contents before installing or configuring Docker. After installation, you can restore the backup. Example of Docker Compose: If you want to manage multiple web applications more easily, you can use Docker Compose. Here’s a simple example: version: '3' services: site1: image: nginx volumes: - ./WWW/site1:/usr/share/nginx/html site2: image: nginx volumes: - ./WWW/site2:/usr/share/nginx/html Summary: You can definitely use Docker and Git with multiple directories and websites. Make sure to organize your directories well, use Docker volumes for persistent data, and consider Docker Compose for easier management. If you have specific questions about any of the steps, feel free to ask! -
Docker and Windows PowerShell config.
LeonLatex replied to LeonLatex's topic in Editor Help (PhpStorm, VS Code, etc)
.... -
I wanted to try Docker to see how it works in my environment. I have a question about the installation that may crash with how I have arranged the folder hierarchy locally on my PC. All my web pages are stored in the www folder, which contains the folders with my web pages. When I install Docker, or rather during the config of Docker when I specify an empty directory in Windows PowerShell, this directory must be empty. One question is: Why is that? The second is: What can happen if that directory is not empty of files and other folders? The WWW directory is empty of files (if you know what I mean) but contains all the directories containing the various web pages I have stored on my developer PC. My third question is: Does it matter if the WWW directory is not empty when I specify this in Windows PowerShell, would it help to move the folders out of the WWW directory until I am finished configuring docker via Windows PowerShell?
-
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> </td> <td>TOTAL DUE</td> <td>£' . number_format($totmoney, 2) . ' </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!
-
Develop a CMS with categories and subcategories in the database.
LeonLatex replied to LeonLatex's topic in PHP Coding Help
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? -
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.
-
@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 ?>
-
@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 😃
-
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 ?>
-
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 ?
-
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."; } } ?>
-
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;
-
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.
-
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; }
-
No, but I fixed it now. I set the charset to utf8mb4. Thanks Barand.