-
Posts
403 -
Joined
-
Last visited
-
Days Won
1
Everything posted by LeonLatex
-
I found the solution my self. - I had to remove the hight on big_div and change it to min-height. - Set the position property of .nav_div to absolute, and position it at the bottom of .big_div. - And I had to remove this line: background-size: contain; /*Makes the background scaling.* Both .big_div and .nav_div is scaling in proportion to the background image in .big_div, and .nav_div stays at the bottom of .big_div when it scales. Case closed.
-
If you suspect that someone is sending spam to you through means other than your website's contact form, there are several things you can do to investigate: Check the email headers: Email headers contain information about the sender, including the IP address and the originating server. You can use an email header analyzer tool to decode the headers and check if the email was sent from your website's server or from a different one. Verify the sender's email address: Check the sender's email address to see if it matches the email address used on your website's contact form. If the email address is different, it is likely that the email was sent from a different source. Use CAPTCHA: Implement a CAPTCHA on your website's contact form to prevent automated spam bots from submitting the form. Implement email authentication protocols: Implement email authentication protocols such as SPF, DKIM, and DMARC to verify that emails sent from your domain are legitimate. Monitor your website's traffic: Use website analytics tools to monitor your website's traffic and look for unusual spikes in traffic or suspicious activity. By taking these steps, you can help ensure that the emails you receive through your website's contact form are legitimate and have been sent from your website's server.
-
It is the background image that is scaling, but the two div's is not. I have removed the img_div so I have just big_div and nav_div left. I thought that maybe this would help. I discovered that it is not the nav_div that is not scaling when I minimize the browser window. It doesn't follow the background picture with the logo and graphic. Because the background picture is scaling as it should. The problem occurs when I minimize the browser window, and the two div's are not scaling like the background image. The background image is scaling because of this one: background: url("../images/topbg.png") no-repeat; background-size: contain; /*Makes the background scaling.*/ First (like in my first posting) I thought that the nav bar was hanging on the same place and the other two div's was scaling. But that wasn't the problem. The problem occurs when the background image is scaling, but the div's is not. How to make this work I don't have a clue, but I hope someone here has and can help. Please, tell me how to solve this problem. I hope this is enough information when I include the screenshots π The CSS is the same as in my opening posting minus the img_div and I also corrected the quoting that was missingπ Maximized Minimized CSS: .big_div { margin: auto; width: 100%; height: 203px; padding-top: 0px; padding-left: 0px; padding-right: 0px; font-size: 14pt; background: url("../images/topbg.png") no-repeat; background-size: contain; /*Makes the background scaling.*/ } .nav_div { background-color: #ff0000; margin: auto; width: 100%; height: 40px; padding-top: 0px; padding-left: 0px; padding-right: 0px; font-size: 13pt; text-align: center; vertical-align: middle; } HTML: <div class="big_div"></div> <div class="nav_div"> <a id="nav-hjem" href="<?=$HOST?>index.php" class="w3-bar-item w3-button">Hjem</a> <a id="nav-jeg" href="<?=$HOST?>index.php" class="w3-bar-item w3-button">Jeg</a> <a id="nav-meg" href="<?=$HOST?>index.php" class="w3-bar-item w3-button">Meg</a> <a id="nav-deg" href="<?=$HOST?>index.php" class="w3-bar-item w3-button">Deg</a> <a id="nav-du" href="<?=$HOST?>index.php" class="w3-bar-item w3-button">Du</a> </div>
-
Hello senenglari, the earth is answering π
-
nav_div remains in the same place when I minimize and scale. It should follow the div above, but doesn't. The width and height scale, but it does not move accordingly. What and where is wrong? CSS: .big_div { margin: auto; width: 100%; height: 201px; padding-top: 0px; padding-left: 0px; padding-right: 0px; font-size: 14pt; } .img_div { width: 100%; height: 203px; background: url("../images/logo.png") no-repeat; background-size: contain; } .nav_div { background-color: #ff0000; margin: auto; width: 100%; height: 40px; padding-top: 0px; padding-left: 0px; padding-right: 0px; font-size: 13pt; text-align: center; vertical-align: middle; } HTML: <div class="big_div"><div class="img_div"></div></div> <div class="nav_div"> <a id='nav-hjem' href='<?=$HOST?>index.php' class='w3-bar-item w3-button'>Hjem</a> <a id='nav-jeg' href='<?=$HOST?>index.php' class='w3-bar-item w3-button'>Jeg</a> <a id='nav-meg' href='<?=$HOST?>index.php' class='w3-bar-item w3-button'>Meg</a> <a id='nav-deg href='<?=$HOST?>index.php' class='w3-bar-item w3-button'>Deg</a> <a id='nav-du' href='<?=$HOST?>index.php' class='w3-bar-item w3-button'>Du</a> </div>
-
Create link out of a global and set a variable
LeonLatex replied to LeonLatex's topic in PHP Coding Help
Thanks for the answer to both of you. I tried as Requinix said to print out the path and found out the difference between those two. -
I have put the PDO database connection one level above (outside) the WWW directory on the server to protect it from unwanted visitors who get hold of the user data of the database server. Today I use this in other places than where it says now, but it is only as an example: include __DIR__ . '/../includes/db.php'; but then I thought of the super global $server , but I can't get it to work. I have set it up like this: include($_SERVER['DOCUMENT_ROOT'] . "../includes/db.php"); What am I doing wrong? Or won't it work with the super global example? And how do I create a variable out of the super global string so I only use $linkpath in front of the path to the file I want to link to?
-
What do you call the small articles that are placed as samples or click bait on the front page. That is, e.g. a picture of the main picture in the article + a small extract of the text in the news article. What are these called in English, is it the same as thumbnail?
-
I used an hour on this. I am not so good at this, so I had to use some extra minutes on it. Hope I am right and you understand it. To edit a database entry using the id, you need to retrieve the id of the record to be edited, and then update the corresponding fields in the database with the new values. Here are the changes you can make to the existing code to enable editing of the database entry using the id: Update the form action to point to the PHP file that will handle the form submission, and pass the id of the record to be edited as a query parameter. For example: <form class="form theme-form" method="POST" action="edit_firm.php?id=<?php echo $firm_id; ?>" autocomplete="off"> Here, edit_firm.php is the PHP file that will handle the form submission, and $firm_id is the id of the record to be edited. Retrieve the id of the record to be edited from the query parameter in the URL. For example: if (isset($_GET['id'])) { $firm_id = $_GET['id']; } else { // handle error if id is not present in URL } Update the SQL query to use the UPDATE statement instead of INSERT, and set the values of the fields to be updated using the form data. For example: $sqleditfirm = "UPDATE firms SET firm_legalname=?, firmbusinessname=?, firmbusiness_addresss=?, firmbusiness_city=?, firmbusiness_state=?, firmbusiness_pin=?, firmbusiness_phone=?, firmbusiness_country=? WHERE id=?"; $stmtditfirm = $conn->prepare($sqleditfirm); $stmtditfirm->bind_param("ssssssssi", $addfirm_legalname, $addfirm_businessname, $addfirm_address, $addfirm_city, $addfirm_state, $addfirm_pin, $addfirm_phone, $addfirm_country, $firm_id); Here, id is the name of the primary key column in the firms table. Retrieve the existing values of the fields for the record to be edited from the database using the id, and prepopulate the form fields with these values. For example: // Retrieve existing values of the fields for the record to be edited $sqlgetfirm = "SELECT * FROM firms WHERE id=?"; $stmtgetfirm = $conn->prepare($sqlgetfirm); $stmtgetfirm->bind_param("i", $firm_id); $stmtgetfirm->execute(); $resultgetfirm = $stmtgetfirm->get_result(); $rowgetfirm = $resultgetfirm->fetch_assoc(); // Prepopulate the form fields with existing values $addfirm_legalname = $rowgetfirm['firm_legalname']; $addfirm_businessname = $rowgetfirm['firmbusinessname']; $addfirm_address = $rowgetfirm['firmbusiness_addresss']; $addfirm_city = $rowgetfirm['firmbusiness_city']; $addfirm_state = $rowgetfirm['firmbusiness_state']; $addfirm_pin = $rowgetfirm['firmbusiness_pin']; $addfirm_country = $rowgetfirm['firmbusiness_country']; $addfirm_phone = $rowgetfirm['firmbusiness_phone']; Note that you also need to handle any errors that may occur during the editing process. For example, you can display an error message if the record with the specified id is not found in the database.
-
Sorry for my English, but to save time I had to use GT on some of my postings. Usually, I don't do that. Sometimes it works well, and sometimes it doesn't. I have read thru your code a couple of times, and I think I understand it. If I don't, please put me on the right track again. I am only a human and not a machine. The possibility of being wrong is there, and I'm not very good at this, but I try. I have not read thru the other answers in the thread, so sorry if I step on someone's toes. Shot in the blind.... From your code, it seems you are using checkboxes to select multiple items for deletion from a table. Right? However, you mentioned that only the first checkbox is working, even when you select the last checkbox. One issue I see with your code is that you are using the same name attribute for all the checkboxes, which means they will all have the same value when they are submitted. This could be causing the problem you are experiencing. To fix this issue, you need to give each checkbox a unique name attribute value that corresponds to the product ID for that particular item. You can do this by appending the product ID to the name attribute value of each checkbox using square brackets, like this: <input type='checkbox' name='check_list[<?= $prod_id ?>]' value='<?= $prod_id ?>' > In the above code, we are appending the product ID to the name attribute value of the checkbox using PHP. This will ensure that each checkbox has a unique name attribute value that corresponds to the product ID for that particular item. Then, in your PHP code, you can loop through the $_POST['check_list'] array to get the product IDs of the selected items, like this: if(!empty($_POST['check_list'])) { foreach($_POST['check_list'] as $prod_id) { // Delete the item with this product ID } } By doing this, you should be able to select multiple items for deletion using checkboxes and delete them successfully.
-
Will flex and flexbox mean the same as setting up the web page with X number of DIV boxes and then controlling them with CSS3. So, if you imagine that the DIV boxes are parallel both vertically and horizontally (like making a grid), they will be adjusted with CSS and form the intended and planned design. Because then you probably also want to make the DIV boxes different in position and size. Is there something here that I am wrong with my assumptions? Is this partly the intention/principle of the flexbox? Much of this I already know, but I need to have it confirmed, because what I read online and in books are so different. It is possible that I am misunderstanding because bad English etc, but a confirmation of what is right and correction of what is wrong would be nice. I have read the PHP documentation as sugested to.
-
Activated or disabled button/link when logged in.
LeonLatex replied to LeonLatex's topic in PHP Coding Help
First of all, I must apologize for asking a question on a Q&A forum. Sorry for that, but thanks at the same time for the help I get. So to what this thread is really about. You are absolutely right Requinix, When you are logged in, the link or button on the navigation bar should be activated, while it should be deactivated/overshadowed when you are not logged in, and I do it in the following way. I only saw now that I have forgotten something important. Namely to add what is written in the header.php file. It is probably very important and I include that too. After I've pasted it in I'll show what I'm doing in trying to get this to work after I had to reconstruct the entire script after breaking what was done for me in an attempt to improve and add features myself, and which therefore turns out to be wrong. By the way. I include the navigation bar too below header.php header.php <?php session_start(); $ROOT = str_replace('\\', '/', $_SERVER['DOCUMENT_ROOT']) . '/'; $HOST = 'http://' . $_SERVER['HTTP_HOST'] . '/'; $disabl1 = isset($_SESSION['member_id']) ? '' : 'w3-disabled'; $disabl2 = isset($_SESSION['member_id']) && isset($_SESSION['isadmin']) ? '' : 'w3-disabled'; $log_btn = isset($_SESSION['member_id']) ? 'Logg ut' : 'Logg inn'; const SYSNAME = 'Management System'; const PAGETITLE = 'Welcome'; const HELPBUTTON = ""; ?> Nav bar <NAV> <div class='w3-bar w3-light-gray w3-margin-bottom' style='height: 39px'> <a id='nav-members' href='<?=$HOST?>index.php' class='w3-bar-item w3-button'>Hjem</a> <a id='nav-register' href='<?=$HOST?>register.php' class='w3-bar-item w3-button'>Registrering</a> <a id='nav-members' href='<?=$HOST?>members.php' class='w3-bar-item w3-button'>Medlemmer</a> <a id='nav-marina' href='<?=$HOST?>marina.php' class='w3-bar-item w3-button'>BΓ₯tplass</a> <a id='nav-invoice' href='<?=$HOST?>invoice/invoice.php' class='w3-bar-item w3-button'>Faktura</a> <a id='nav-login' href='<?=$HOST?>login.php' class='w3-bar-item w3-button w3-right'><?=$log_btn?></a> </div> </NAV> Here's what I tried to get it to work: <?=$disabl1?> or <?=$disabl2?> All this do is too write "w3-disabled" on the navigation button. Will say, I do it the same way as it is done with login.php link in the navbar above. Another error is that I have administrative rights regardless of whether I am logged in or not. I don't understand what I'm doing wrong or where, and after all the work I had to reconstruct the system, I don't dare touch it too much. -
Barry made this, and the intention is to have the link activated only when logged in as a user or admin. I don't remember how it was set up. Somehow this is controlling the login users rights depending on the email address, which is the username. I paste the sessions from the header.php, members.php and marina.php and the rest of the sites containing the content. I also attached other things related to the log in such as e.g. database etc. If there is something you feel I have forgotten, I hope you will ask. I only try to keep the post as short as possible. I want the user rights to be right again. Do you understand what I mean? Can you help me?, please members.php session. <?php session_start(); $ROOT = str_replace('\\', '/', $_SERVER['DOCUMENT_ROOT']) . '/'; $HOST = 'http://' . $_SERVER['HTTP_HOST'] . '/'; $disabl1 = isset($_SESSION['member_id']) ? '' : 'w3-disabled'; $disabl2 = isset($_SESSION['member_id']) && isset($_SESSION['isadmin']) ? '' : 'w3-disabled'; $log_btn = isset($_SESSION['member_id']) ? 'Logg ut' : 'Logg inn'; const SYSNAME = 'Nikolivia Maraina Management System'; const PAGETITLE = 'Velkommen'; const HELPBUTTON = ""; ?> marina.php session. <?php session_start(); include $ROOT.'db_inc.php'; $pdo = pdoConnect(); $loggedin = $_SESSION['member_id'] ?? 0; unset( $_SESSION['member_id'], $_SESSION['isadmin']); if ($loggedin) { header("Location: {$HOST}marina.php"); exit; } ?> The database part with the records containing the user rights level settings. Here comes some of the HTML/PHP. login.php <?php session_start(); include $ROOT.'db_inc.php'; $pdo = pdoConnect(); $ROOT = str_replace('\\', '/', $_SERVER['DOCUMENT_ROOT']) . '/'; $HOST = 'http://' . $_SERVER['HTTP_HOST'] . '/'; $loggedin = $_SESSION['member_id'] ?? 0; unset( $_SESSION['member_id'], $_SESSION['isadmin']); if ($loggedin) { header("Location: {$HOST}members.php"); exit; } $msg = ''; if ($_SERVER['REQUEST_METHOD']=='POST') { $res = $pdo->prepare("SELECT password , member_id , admin FROM member WHERE email = ? "); $res->execute([ $_POST['email'] ]); $row = $res->fetch(); if ($row && password_verify($_POST['password'], $row['password'])) { $_SESSION['member_id'] = $row['member_id']; if ($row['admin'] == 1) { $_SESSION['isadmin'] = 1; } header("Location: {$HOST}members.php"); exit; } else $msg = "<div class='w3-panel w3-red w3-padding'><p>Ugyldig innlogging</p></div>"; } ?> <?php session_start(); $ROOT = str_replace('\\', '/', $_SERVER['DOCUMENT_ROOT']) . '/'; $HOST = 'http://' . $_SERVER['HTTP_HOST'] . '/'; $disabl1 = isset($_SESSION['member_id']) ? '' : 'w3-disabled'; $disabl2 = isset($_SESSION['member_id']) && isset($_SESSION['isadmin']) ? '' : 'w3-disabled'; $log_btn = isset($_SESSION['member_id']) ? 'Log out' : 'Login'; const SYSNAME = 'Management System'; const PAGETITLE = 'Login'; const HELPBUTTON = ""; ?> <!DOCTYPE html> <html lang='en'> <head> <title><?=SYSNAME?></title> <meta http-equiv='Content-Type' content='text/html; charset=utf-8'> <link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css"> <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.15.1/css/all.css"> <link href='css/footer.css' rel='stylesheet' type="text/css"> </head> <body> <div class='w3-content w3-card-4 w3-light-gray' style='margin-top: 100px;'> <div class='w3-panel w3-black w3-padding'> <?=SYSNAME?> - <?=PAGETITLE?> </div> <?=$msg?> <form method='POST' class='w3-padding'> <label>E-mail</label> <input type='text' class='w3-input w3-border' name='email'> <label>Password</label> <input type='password' class='w3-input w3-border' name='password'> <br> <button type='submit' class='w3-button w3-blue w3-right'>Logg Inn</button> <br><br><br> </form> </div> </body> </html>
-
I am working on and trying to further develop the member and invoice system for another project. Barand was the one who helped me with this and developed it for me from the start, but since I can't get in touch with him anymore I have to ask you guys. In any case, I can no longer see him online either here on PHP Freaks or on Skype. I guess I haven't seen him online since mid-March. so I need some help to look at what I need to activate on the server, and how this should be configured so that a pdf invoice is automatically sent by email when a new registration occurs on the website. To start somewhere... Barand integrated a mail system to have it to automatic send mail to one to three people simultaneously when a new member registration is sent from the registration form. I can't remember what he used when he developed this, I know it isn't the usual php sendmail in linux. I cant find any trace of it in the scripts. Can you imagine what it is?
-
Thank you for a very good answer that was very explanatory and comprehensive. Thanks, requinix πππ
-
I'm browsing different documentation for HTML5, and I'm going to familiarize myself with version 5 of HTML, and the version I was familiar with was HTML 4.01. It's not easy to catch everything when you have to constantly look up and down, back and forth to find answers, because there is a lot that is new for me. So, I'm asking here. These examples: <HEADER> <NAV> <MAIN> <FOOTER> . What are these called? Are they only called a TAG(s), or do they have a special/own name?
-
Yes, I have found that too, but I don't know of another place to do this or another way to do it. I am stuck as a duck.
-
Yes, I re-wrote the whole script (file). That fixed all the problems, but not this one.
-
I need help deciphering this error message. I can't figure it out myself and I can't see anything wrong with it. Can you see where the error(s) are? Error message in browser: ArticleWebsite.php: DatabaseTable.php:
-
Why does your error script report itself? It does so on line 3. <?php error_reporting(E_ALL); ini_set('display_errors', '1');
-
Yes, I understand that. But does it add only the www.domain, domain, or the full path from which directory on the server it is placed inside the file?
-
What's the differences between include and include __DIR__ . '/../includes/DatabaseConnection.php';
-
syntax error unexpected 'public' (t_public)
LeonLatex replied to LeonLatex's topic in PHP Coding Help
Thanks. Hope this will bring me on the right path. -
syntax error unexpected 'public' (t_public)
LeonLatex replied to LeonLatex's topic in PHP Coding Help
Ok, here it is. Thanks for the CTRL+Z. I re-wrote the script, but it was more errors than the first one, so I post the old one. The same errors and amount of them. <?php class databaseTable { public function __construct(private PDO $pdo, private string $table, private string $primaryKey) { } public function find($field, $value) { $query = 'select * FROM `' . $this->table . '` WHERE `' . $field . '` = :value'; $values = [ 'value' => $value ]; $stmt = $this->prepare($query); $stmt->execute($values); return $stmt->fetchAll(); } public function findAll() { $stmt = $this->pdo->prepare('SELECT * FROM `' . $this->table . '`'); $stmt->execute(); return $result->fetchAll(); } public function total() { $stmt = $this->pdo->prepare('SELECT COUNT(*) FROM `' . $this->table . '`'); $stmt->execute(); $row = $stmt->fetch(); return $row[0]; } public function save($record) { try { if (empty($record[$this->primaryKey])) { unset($record[$this->primaryKey]); } $this->insert($record); } catch (PDOException $e) { $this->update($record); } } private function update($values) { $query = ' UPDATE `' . $this->table .'` SET '; foreach ($values as $key => $value) { $query .='`' . $key . '`= :' . $key . ','; } $query = rtrim($query, ','); $query .= ' WHERE `' . $this->primaryKey . '` = :primaryKey'; //Set the primary key variable $values['primaryKey'] = $values['id']; $values = $this->processDates($values); $stmt = $his->pdo->prepare($query); $stmt->execute($values); } private function insert($values) { $query = 'INSERT INTO `' . $this->table . '`('; } foreach ($values as $key => $value) { $query .= '`' . $key . '`,'; } $query = rtrim($query, ','); $query .= ') values ('; foreach ($values as $key => $value) { $query .= ':' . $key . ','; } $query = rtrim($query, ','); $query .= ')'; $values = $this->processDates($values); $stmt = $this->pdo->prepare($query); $stmt->execute($values); } public function delete($field, $value) { $values = [':value' => $value]; $stmt = $this->pdo->prepare('DELETE FROM`' . $this->table . '` WHERE `' $field . '` = :value'); $stmt->execute($values); } function processDates($values) { foreach ($values as $key => $value) { if ($value instanceof DateTime) { $values[$key] = $value->format('Y-m-d'); } } return $values; } } -
syntax error unexpected 'public' (t_public)
LeonLatex replied to LeonLatex's topic in PHP Coding Help
Yes, i am on my way. I post it as text when i am finished.