-
Posts
24,425 -
Joined
-
Last visited
-
Days Won
806
Posts posted by Barand
-
-
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
-
UPDATE tableZ SET x = (x = 0) WHERE id = 1
- 1
-
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.
-
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 | curly@abc.com | $2y$10$OKAmeyWZpKJcg/VgPAcx3uQr7R1KF23pPZFapmOmn0BhnWLqqVAP6 | user | | 2 | larry@abc.com | $2y$10$NeqCtTFo79wxGyAacPJLbeyU7Er4hPKrjwZv1G/Vr6YgHV/vnV9.6 | std | | 3 | mo@abc.com | $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> </label><input type="submit" name="sb" value='Log In'> </fieldset> </form> <?=$messages?> </body> </html>
-
Do you have a particular reason for posting that mess?
-
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?
-
I gave you the code to show the before and after exif data. How much of clue do you need?
-
So our giving you yet another example would just be a waste of time, wouldn't it?
-
Have you looked at the examples on the pages you've been linked to? How do they NOT help?
-
I'd put the items in an array then use array_chunk()
-
elseif (is_numeric($minPrice))
probably needs to be
elseif (!is_numeric($minPrice)) // error if NOT numeric
- 1
-
24 minutes ago, phppup said:
I am starting with File A and altering it and overwriting it as File A again.
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>';
-
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)
-
, 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.
-
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.
-
@cyberRobot seems keen on this topic, so I'll leave you in his capable hands.
-
One way is to edit the code, changing $_GET['city'] to $_POST['city'].
-
Note, from that output, there is no $_GET['city']. This isn't surprising as you form's method is POST.
Try checking for $_POST['city'] instead.
-
It might be an idea to check what your script is receiving in the GET and POST array. At top of the script, put
echo '<pre>GET = ', print_r($_GET, 1), '</pre>'; echo '<pre>POST = ', print_r($_POST, 1), '</pre>';
-
First thing to do then is fix those errors.
-
If you put those 2 lines back in, what error messages do get?
-
If you are having problems why have you commented out the two lines at the top that might tell you why you are having those problems?
-
You need to assign the value returned by your function to a variable.
$photoFiles = getPhotoFilesArray($photoPath); var_dump($photoFiles);
I suggest you read up on
- how to use functions
- variable scope
-
1 hour ago, benanamen said:
Why do you have duplicate table structures? This points to a design flaw.
Not necessarily
TABLE customer TABLE customer_order +--------------+ +------------------+ | customer_id | | order_no | | cust_name | | order_date | | address | | customer_id | +--------------+ | deliver_to | +------------------+ SELECT cust_name , order_no , order_date , COALESCE(deliver_to, address) as deliver_to FROM customer_order o JOIN customer c USING (customer_id)
disable button if value exists or equal to array
in PHP Coding Help
Posted
What is the query to get $row?
What is the query to get $row2?
(If you used "SELECT * ' the provide the table structures too)