Jump to content

Barand

Moderators
  • Posts

    24,608
  • Joined

  • Last visited

  • Days Won

    831

Everything posted by Barand

  1. Thanks, that loaded OK. I'll look at your problem, which I interpret as ranking the menus by percentage of content of the ordered items. I expect there could be a situation where items A,B,C,D,E are ordered menu 1 contains A,B,C. menu 2 contains B,C,D menu 3 contains C,D,E ie No single menu contains all items ordered?
  2. Tell me how to load those images into a test database and I'll continue to help.
  3. Can you provide some actual data that might give us more of an insight into what you want - a dump of those tables perhaps?
  4. The question has been answered as detailed as we can from the information provided.
  5. Here's a simplified example $uid = 2; $res = $bdd->prepare("SELECT f.id , f.name , u.file_id FROM files f LEFT JOIN user_files u ON f.id = u.file_id AND u.user_id = ? ORDER BY f.id "); $res->execute([$uid]); $tdata = ''; foreach ($res as $row) { $disabled = $row['file_id'] ? 'disabled' : ''; $tdata .= "<tr> <td>{$row['id']}</td> <td>{$row['name']}</td> <td><button $disabled>Download</button></td> </tr> "; } ?> <html> <head> <title>Example</title> </head> <body> <table> <?=$tdata?> </table> </body> </html>
  6. Have you tried recreating test files in your database using images as input? SHOW CREATE TABLE files; SHOW CREATE TABLE user_files; Use a single query on both tables and use a LEFT JOIN. That way you know which are present in both tables. Disable the button where the file is in both.
  7. Only select check boxes (and radio buttons) are sent in the form data so you need you check if they are present using isset(). Example <?php for ($i=1; $i<=5; $i++) { if (isset($_GET['mycb'][$i])) { echo "Check box $i selected<br>" ; } } ?> <html> <head> <title>Example</title> </head> <body> <hr> <form> Check box 1 : <input type="checkbox" name="mycb[1]" value="1"><br> Check box 2 : <input type="checkbox" name="mycb[2]" value="2"><br> Check box 3 : <input type="checkbox" name="mycb[3]" value="3"><br> Check box 4 : <input type="checkbox" name="mycb[4]" value="4"><br> Check box 5 : <input type="checkbox" name="mycb[5]" value="5"><br><br> <input type="submit" name="btnSub" value="Submit"> </form> </body> </html>
  8. What is the query to get $row? What is the query to get $row2? (If you used "SELECT * ' the provide the table structures too)
  9. If it toggles every hour then the time-based value does not require a cron job. The value is available anytime you need it SELECT HOUR(NOW()) MOD 2 as value
  10. UPDATE tableZ SET x = (x = 0) WHERE id = 1
  11. A couple of methods spring to mind 1 ) toggle the value between 0 and 1 ... UPDATE tableZ SET x = CASE WHEN x = 1 THEN 0 ELSE 1 END; or UPDATE tableZ SET x = (x = 0); 2 ) set it based on the time UPDATE tableZ SET x = HOUR(NOW()) MOD 2; Of course the queries may need a WHERE clause unless you want to apply the change to every record in tableZ.
  12. As @mac_gyver said, when the user registers, create a hash of their password using password_hash() and store that hash value, not the plain-text value. You then verify the password hash using password_verify() (See line 36 in the code) That being said, my test table for the code below is ... CREATE TABLE `sam_user` ( `user_id` int(11) NOT NULL AUTO_INCREMENT, `eml` varchar(50) DEFAULT NULL, `pass` varchar(120) DEFAULT NULL, `type` varchar(10) NOT NULL DEFAULT 'user', PRIMARY KEY (`user_id`), UNIQUE KEY `idx_sam_user_eml` (`eml`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; +---------+---------------+--------------------------------------------------------------+-------+ | user_id | eml | pass | type | +---------+---------------+--------------------------------------------------------------+-------+ | 1 | [email protected] | $2y$10$OKAmeyWZpKJcg/VgPAcx3uQr7R1KF23pPZFapmOmn0BhnWLqqVAP6 | user | | 2 | [email protected] | $2y$10$NeqCtTFo79wxGyAacPJLbeyU7Er4hPKrjwZv1G/Vr6YgHV/vnV9.6 | std | | 3 | [email protected] | $2y$10$6TBuStg179rLeMOm2URoNuwEOseYyOIXEVTvbwq7x9G5c9Jw0Bxoi | admin | +---------+---------------+--------------------------------------------------------------+-------+ This is my version of your code ... <?php session_start(); include 'db_inc.php'; // database credentials and custom pdoConnect function $db = pdoConnect('test'); // connect to DB 'test' using PDO // DEFAULT FORM VALUES $eml = ''; $pass = ''; $messages = ''; // HAS FORM DATA BEEN POSTED? if ($_SERVER['REQUEST_METHOD'] == 'POST') { $post = array_map('trim', $_POST); $eml = $post['eml'] ?? ''; $pass = $post['pass'] ?? ''; $errors = []; if ($post['eml']=='') { $errors[] = 'You must enter your email address'; } if ($post['pass']=='') { $errors[] = 'You must enter your password'; } $stmt = $db->prepare("SELECT user_id , pass , type FROM sam_user WHERE eml = ? "); $stmt->execute([$post['eml']]); $row = $stmt->fetch(); if (!$row) { $errors[] = "Invalid login request"; } else { if (!password_verify($post['pass'], $row['pass'])) { // verify the hashed password $errors[] = "Invalid login request"; } } if (!$errors) { $_SESSION['user'] = $row['user_id']; $qdata = []; switch ($row['type']) { case 'admin': $page = 'wel.php'; $qdata['msg'] = 'Administrator successfully logged in'; break; case 'std': $page = 'mod.php'; $qdata['msg'] = 'Moderator successfully logged in'; break; default: $page = 'sim.php'; $qdata['msg'] = 'User successfully logged in'; break; } $qstr = http_build_query($qdata); $url = "{$page}?{$qstr}"; // header("Location: $url"); // uncomment in production version echo $url; // TESTING ONLY exit; } else { unset($_SESSION['user']); $messages = "<div class='errors'>" . join('<br>', $errors) . "</div>\n"; } } ?> <!DOCTYPE html> <html> <head> <meta http-equiv="content-language" content="en"> <meta charset="utf-8"> <title>Example Login</title> <style type="text/css" media="screen"> body { font-family: calibri, sans-serif; font-size: 12pt; } header { padding: 25px; text-align: center; background-color: #2DABE1; color: #FFF;} label { width: 100px; height: 40px; font-weight: 600; display: inline-block; } fieldset { width: 300px; margin: 100px auto; padding: 20px; } .errors { width: 300px; background-color: #E02222; color: #FFF; margin: 0 auto; padding: 20px;} </style> </head> <body> <header> <h1>Example Login</h1> </header> <form action="" method="post"> <fieldset> <label>Email</label><input type="text" name="eml" value='<?=$eml?>'><br> <label>Password</label><input type="password" name="pass" value='<?=$pass?>'><br> <label>&nbsp;</label><input type="submit" name="sb" value='Log In'> </fieldset> </form> <?=$messages?> </body> </html>
  13. Do you have a particular reason for posting that mess?
  14. It's a simple enough process Get exif data from the original image and print it Rotate the image Get the exif data from the rotated image and print it What in there is so difficult?
  15. I gave you the code to show the before and after exif data. How much of clue do you need?
  16. So our giving you yet another example would just be a waste of time, wouldn't it?
  17. Have you looked at the examples on the pages you've been linked to? How do they NOT help?
  18. elseif (is_numeric($minPrice)) probably needs to be elseif (!is_numeric($minPrice)) // error if NOT numeric
  19. Then it sounds like your rotation function is the same as you posted earlier - yes? $filename = '/images/myphoto.jpg'; $exif = exif_read_data($filesname); echo '<pre>BEFORE: ' . print_r($exif, 1) . '</pre>'; correctImageOrientation($filename); $exif = exif_read_data($filesname); echo '<pre>AFTER: ' . print_r($exif, 1) . '</pre>';
  20. You start with FileA. You rotate it and store it in FileB. If you now output the exif data for FileA then of course it's the same. You need to get the exif from FileB to see changes (but there won't be much exif data there)
  21. , COALESCE(oc.recipient_address_line_1, mailAddr.Address_Line_1) as RecipientAddress1 etc instead of the two address_Line_1 columns. Do same for each address column.
  22. If the exif data is the same you must be getting it from the same file. Try getting the exif data from the rotated file.
  23. @cyberRobot seems keen on this topic, so I'll leave you in his capable hands.
  24. One way is to edit the code, changing $_GET['city'] to $_POST['city'].
×
×
  • 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.