Jump to content

kicken

Gurus
  • Posts

    4,704
  • Joined

  • Last visited

  • Days Won

    179

Everything posted by kicken

  1. You can use a table in a form, but you can't embed the form within the table the way you did. A <tbody> element can only contain <tr> elements, not <form> elements. Move your form outside of the table entirely. <form method="post"> <table> ... </table> </form>
  2. I can tell you that is_readable works just fine for me when accessing files on a mapped network drive. The drive in my case is mapped to a share provided by another windows 10 machine. I'd suspect your problem is related to either permissions or the NAS's software.
  3. You could use something like DateTime::createFromFormat() to try and parse the date. If it fails to parse, invalid format. If a valid date is created, you'll need to check it matches the input by comparing the input to the formatted date. This is because the function will "fix" invalid dates, for example 07/35/2022 would parse as 08/04/2022. <?php $input = '07/31/2022'; $date = DateTime::createFromFormat('m/d/Y', $input); if (!$date || $date->format('m/d/Y') !== $input){ echo 'Invalid date'; } else { echo 'Valid date'; } Any validate beyond that depends on what you need from the data. For a birthday for example, you might validate it's in the past and not in the future.
  4. You're including your app/index.php file inside your Route::add function. As such, it's variable scope is the same as that function. $test does not exist within that scope (it's in the global scope) so you're getting an undefined variable error. I would suggest creating another class which handles including your content file as well as setting up any variables you want to be defined within it's scope.
  5. The parameter names in the query and the keys in your array need to match. You've defined your parameters for the name as first_name and last_name, but in your array you used fname and lname. Also post_code vs postcode, birthdate vs birthday.
  6. Use an <iframe>. <iframe src="thepdf.pdf"></iframe>
  7. You'd probably just want to talk to your hosting company to determine if there is a cache and if so, what you can do about it. Alternatively, setup your own local development environment so you have control over such things.
  8. If you want a checkerboard pattern (which is what you described I guess) rather than a stripped pattern (which is more typical), you can do that with css as well. td { background-color: white; } tr:nth-child(2n+1) td:nth-child(2n+1), tr:nth-child(2n) td:nth-child(2n) { background-color: pink; }
  9. Your code is incorrect. You're not echoing your table cells, you storing them in a variable that is never used. Your opening <td> tag is missing it's >. You cannot do an expression inside a string. Either do it outside the string and save the result to a variable then embed the variable, or use concatenation. Lastly, you can do alternating colors with simple CSS and just create your table normally. td { background-color: white; } td:nth-child(2n){ background-color: pink; }
  10. Sounds like the most likely cause is you accidentally uploaded the wrong file, uploaded to the wrong path, or edited the wrong file. If not that then maybe some server-side caching is in place that you need to either disable or find a way to clear.
  11. Did you add the PDO::SQLSRV_ENCODING_BINARY parameter? It prevents that error.
  12. Years ago I did a security audit of a company's code. In their admin area they had code to check for admin rights like: if (!$_SESSION['isAdmin']){ header('Location: /login.php'); } //Do the admin stuff. No exit. It appeared to work fine at first glance, the user was redirect to the login page if they were not an admin user. I highlighted this and told them they had to add the exit or some other way of stopping the script. I demonstrated this by directly loading one of their admin pages to delete a piece of content while not being logged in. I got sent to the login page as expected, but the selected piece of content was also unexpectedly deleted from the database. So while a person couldn't just casually browse the admin area, if they knew the proper URLs and request data they could still essentially do whatever they wanted because of that missing exit call.
  13. No, there's no doubt about it's standardization. It's part of the CSS Positioned Layout Module Level 3. It seems to be well supported as well. Your editor probably just doesn't recognize it for some reason, perhaps out of date syntax definitions.
  14. Then either use _blank, or generate a new unique target name for each submission. If you generate new unique names, remember to use the name both in the window.open call and in the forms target attribute (update it in the submission handler).
  15. If you just want a new window/tab without and special properties then simply add a target attribute to your form tag. <form method="post" action="processing.php" target="_blank"> If you want to customize the popup window, add the target attribute and an onsubmit handler that open a window with the appropriate name. <form method="post" action="processing.php" target="formResults" onsubmit="openWindow()"> function openWindow(){ window.open('', 'formResults', 'width=800,height=600'); }
  16. Seems outdated/incorrect. I'd recommend you just bookmark something like the MDN Reference. That's what I do.
  17. The way I understood your question here was if you should have a wrapper around the entire content of your page, ie: <body> <div id="wrapper"> Your content all goes here </div> </body> Doing such a thing is largely unnecessary I believe. The body tag works just fine as a wrapper. I believe in the past such a thing was common to fix the width of a page and center it in the view port as applying the necessary styles directly to <body> didn't work. I believe these days those issues have been resolved, and that design isn't very common anymore anyway. There might still be reasons one could want to do such a thing, but I can't think of any. In any case, it's not something you should inherently do, only do it if you have a reason. If my understanding if your wrapper question is accurate, then no they are not the same. The flex container is just something you apply display: flex; to in order to activate a flex layout. You can't use flex without it, but it doesn't have to wrap the whole site, just whatever elements you want to be part of the flex. I typically use flex for smaller components in a page rather than as a larger page layout tool. I find myself tending to use grid over flex these days though. The box model is the low-level workings of how elements are sized, how padding, margins, and borders work, etc. Flex / grid are higher-level layout tools that let you control how elements are positioned in the page. Flex allows you to easily put things in a single line without any gaps if you want, or you can easily distribute items so that they are evenly spaced with a consistent gap. Not sure if that's what you were wondering about or not. You may have to dig up whatever prompted that question and re-ask. Flex and grid are about being able to essentially scale / re-arrange your site according to the available space. Flex allows elements to size them selves according to the available space while remaining grouped together. This makes it simpler to do something like create a bar the spans the entire page width and divide it into sections that can scale proportionally. You can do the same with floats and px and % but it's more difficult and error prone. Grid is similar to old table designs in that you define a grid of squares and can position your content into / across specific squares. -- As an aside, it's easier to understand posts if you put your responses outside of quotes rather than inside them. You can quote part of a post by highlighting the text and clicking the popup Quote Selection button, or just quote the whole post then edit the quote down to what you want. Then click below the quote in the editor to move the cursor outside of it and begin your response.
  18. It's not just the decimals that you didn't consider / include in the problem description. If decimals were the only thing, then Barand's solution would have still worked fine as it was ok with decimals. You also should have considered / mentioned this part from the beginning: So you were not just looking for a number in a string, you were trying to find a specific number in a string that possibly contains multiple numbers. It's good to try and simplify the problem in general, you just need to be careful not to simplify it too much.
  19. What you should do is spend a little time learning regular expressions, and play with them to find a working pattern. The pattern \d matches only digits (ie, 0 - 9). As such, it'll only match numbers the consist of simply digits (no decimals, no grouping characters). If you want to match decimals, you'd need to add . to the list of allowed characters. You can do that by specifying a set of possible characters using [ ]. Joe has ([\d.]+) large apples If you needed groups, you could likewise add , to the set.
  20. You need to use bindParam(). Set the type as PDO::PARAM_LOB so you can bind a file resource and stream the data (rather than as a big string), and use the $driverOptions parameter to set the data type to binary. $dbStatement = $db->prepare('INSERT INTO uploads (file_application_id, file_type, file_name, file_data) VALUES (?, ?, ?, ?);'); $dbStatement->bindValue(1, $appid['appid']); $dbStatement->bindValue(2, $attachment['type']); $dbStatement->bindValue(3, $fname); $fp = fopen('c:\\uploads\\'.$attachment['name'], 'r'); $dbStatement->bindParam(4, $fp, PDO::PARAM_LOB, 0, PDO::SQLSRV_ENCODING_BINARY); $dbStatement->execute();
  21. The installer lets you select which software you want to install. You would install MySQL server by clicking the Add... button on the side and choosing mysql server. This would install it independently from whatever this Laragon is that you're using though.
  22. A few rows of the raw data from the tables you're trying to query, or a similar representative set of data. An example of the output you want to generate using the given data would help as well.
  23. As an alternative to making your own proxy server (or finding one) you might be able to simply configure Nginx to authenticate the request for you by making a sub-request to your PHP script. I don't use Nginx so not sure if that would work but it sounds promising.
  24. That's exactly the issue. Websockets are a persistent and bi-directional connection, unlike your typical http requests. This means they don't really work with your typical HTTP tools, you need something that can specifically deal with websockets. As far as I know you can't really use PHP to deal with a websocket via apache, nor do I expect it to be a good idea even if you could. What you'd typically do is essentially write your own websocket server in PHP that is run as it's own service, separate from apache or nginx. You could then code your server to act as a proxy between the vnc server and the browser with whatever extra checks you want.
  25. It might just be an issue with their device and not an issue with the code itself. Have you tried replicating it with a similar device (iOS + Safari)? If it works for you even with the same type of device, than I'd suggest that something about their setup is either causing the browser to ignore the headers or possibly striping the headers (proxy?) and causing the browser to display the content. If there were problems with output before the headers you should be seeing a message about it if you have display_errors=on. However just to be sure, I'd suggest checking the result of the request to ensure the headers are being sent. You may be able to do that using the browsers developer tools, or use curl with the -i flag to request the URL.
×
×
  • 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.