Jump to content

requinix

Administrators
  • Posts

    15,066
  • Joined

  • Last visited

  • Days Won

    414

Everything posted by requinix

  1. Have you considered, perhaps, writing some code to do that?
  2. Then either you didn't have PHP set up at all, and what you were seeing was the unexecuted source, or (I assume) you have some kind of logic like "if (form submitted) { do thing } else { show page }" and you weren't triggering the "form submitted" logic (thus it was returning the regular page instead).
  3. Looks normal... You do Bearer authentication by just including an Authorization header in the request. Like if it was any other header. Was the 500 coming from your own site or from theirs? Presumably yours. A 500 means an error, so if you get that then check the server logs to find out what the error is so you can fix it. If the "HTML source" is of a page on their site then that likely means you were sending an incorrect request and/or to the wrong URL.
  4. If your script is working correctly then there will always be output - except in the case that there was no "register" submitted with the form. So first thing is to check that. Otherwise you'll have some sort of error. Make sure your php.ini is set up appropriately for a development environment by ensuring it has these two settings: display_errors = on error_reporting = -1 (like at the bottom) and then restart PHP/the server/whatever you're using. You should then end up with a not-blank page...
  5. 1. Thank you for posting your reCAPTCHA secret to a public forum. Please cancel it and generate a new one immediately. And then don't publish it anywhere. 2. The URL you're constructing has two problems, but they're irrelevant because: 3. Per the documentation, you need to send a POST request to /siteverify. Not a GET request. Which typically means using cURL. If you still have problems, remember to post your updated code.
  6. Is it possible you're not aware that foreach can give you both the keys and the values? That said, you shouldn't be going through every single entry in $_POST without verifying that it's good to add to your SQL. Really, you should be starting with the list of columns you want to support and then looking in $_POST to see what each one's value is.
  7. It'll be finding two versions because you do have two versions: it can't tell that the index.php one is "the homepage" and you're (I assume) using URL rewriting in the backend to map / to /index.php?route=common/home. Redirects are the answer, however they have to be very carefully done: redirect from the ?route= thing if that was the actual URL requested. Because if you don't have that little condition at the end, your server will redirect back and forth between them. How are your redirects set up now?
  8. Sounds like the preprocessing you're doing on your data, namely the $results array, doesn't suit your needs. Take a sample of your data and write it directly into your code, putting it into an array format that you can work with. Toy around with it until you get something that works. Then pull that stuff out and write code to generate the array from $data. Advice: it's totally okay to have something more complicated than a plain 3D array. array( some info here, sub data => array( maybe more info here, sub data => array( stuff ) ) )
  9. How about some details? How was it created? On what schedule? What do you mean by "afterwards"?
  10. That's correct: an ID will only ever refer to one element on the page, so using it for multiple elements is always incorrect. There's a simple solution for you here. Wrap the NOW PLAYING and the button (both) in a container element, then when the button is clicked, have it locate the container and then find the desired element to copy inside of it. IIRC: <div class="copy-container"> <div class="copy-target">NOW PLAYING: Something</div> <button class="copy-button">COPY</button> </div> <script> document .querySelectorAll(".copy-container") .forEach(container => { const target = container.querySelector(".copy-target"); const button = container.querySelector("btn.copy-button"); button.addEventListener("click", () => { copyToClipboard(target); }); }); </script> And please don't implement clipboard functions like that - use the actual Clipboard API instead.
  11. Moved. That is typically why people install Apache, or bundles like WAMP and XAMPP. First piece of advice is that generating HTML files is probably the wrong way to do this. How about some more information? What is it you're developing? What are these text files and HTML files?
  12. Code your bot as a system service, as in something that runs on system startup and probably has a dependency or two (such as networking). Doing that also means the system can monitor the process and restart it if it fails. Yes, that means you need to spend a bit of time learning what those are and how they work, though that shouldn't take long. The only difference between a "normal" service and your bot's service is that the command to run your bot looks like "/usr/bin/php /path/to/your/bot.php".
  13. A <tr> is a table row. A <td> is a table cell. If you want one row with multiple cells then you need one <tr> and multiple <td>s.
  14. That's floating-point arithmetic: the computer can't calculate 573.06 * 100 exactly so it comes up with something close. Something like 57305.9999999999986. And if you truncate that, like with an int cast, then you'll just get 57305. In other cases it might come up with 57306.00000000000005. The solution is super simple: round the number instead of truncating it. function convertToMoneyInteger($input) { return round($input * 100); } Be careful that your $input is never going to have fractional cents or you'll lose them by rounding to 0 digits. If you're concerned that might be possible, round to an appropriate number of decimal places.
  15. Tip: if you want to use programming to make your work easier, you should try considering yourself a programmer. So, what have you tried to do so far?
  16. 1. What have you tried so far? 2. Are you aware that PHP has a variety of DNS functions already?
  17. It's not possible to book a particular seat in the theater. (Most likely.) Instead, one has to book a particular seat in the theater for a particular screening. Thus the status must be associated with something that has both of those pieces of data. You don't have such an entity... basically. You could build one by creating a "screening_seat" table, consisting of a screening_id and seat_id. Rows could be created on-demand, removing the need to pre-populate that table when a screening is created. You would then adapt the booking_details to reference that screening_seat instead. However, if the status is a simple boolean "booked / not booked" then you don't need to store it because it can be inferred from the existence of a booking for a seat. In other words, with the current design, if there is a booking_details with seat_id = $seat and booking.screening_id = $screening then the seat is considered booked, and if not then the seat is considered free.
  18. You've posted bits and pieces. If there's nothing more to it and you've shown us everything then the answer is simple: you can't call PHP functions from Javascript like that. But I suspect you haven't posted everything. Please do.
  19. As mentioned on Discord, if you want wincache because it can cache PHP code, then use opcache instead: it does the same thing, except it's part of the PHP core instead of being some third-party, Windows-only extension.
  20. The main problem is that this $email_to = "email1@website.com", "email2@whatever.com"; isn't going to work. You can't just list multiple email address strings like that. But before that, the other problem is that you're manually trying to send emails. That's almost always bad: emails are hard, and doing it yourself is pretty much always going to go badly. Switch to a library like PHPMailer or SwiftMailer, which will not only be able to do emails properly but also make it easier to do things like add multiple recipients.
  21. Send one of those emails to yourself and check the full source (or whatever your client calls it) of the message to see what the Return-Path is. Was it possibly overwritten by some other value?
  22. Not quite. Yes, it's displaying the confirmation after you click the button, but it's not displaying it because you clicked the button. What's happening is that you clicked the button (event #1) and then the button, having no other behavior imposed on it to override the default, causes the form to submit (event #2), and that shows the confirmation. Additionally, "srcElement" is old, and what you should be using instead of it is "target". And that name communicates the purpose better: it isn't the "source element" of an event, which suggests that it's some element responsible for the event, but rather it's the target of the event - the thing the event is addressing. It's a distinction that matters because of how events work and the fact that you can - and will, if you're not careful - receive events for child elements. So the target (aka srcElement) during the onsubmit is going to be the form. Not whatever thing that you interacted with that set about the chain of events causing the form to be submitted, but the form the event is associated with. Or another way to think about it is, your code is paying attention to the form being submitted when you actually wanted to pay attention to a button being clicked, and that mismatch is your problem. But anyway, that "receive events for child elements" thing I said earlier is useful because it means you have a way to listen for a click event on any button in the form by listening to the form itself. That means you don't have to loop over the form's buttons, and you can use a single event handler. jQuery makes doing this easy because you can tell it to (1) listen to the form (2) for a click event (3) triggered by a button. $("#myform").on("click", "button.form-button", () => { ... }); Native DOM only does the first two parts so you have to handle the third yourself, which isn't hard since .matches exists. document.querySelector("#myform").addEventListener("click", (e) => { if (e.target.matches("button.form-button")) { // e.target is the button, e.currentTarget is the form } });
  23. Object-oriented programming tends to be one of those things that doesn't really make sense until you find the right piece of information, or read something phrased in just the right way, or happen to be in the right frame of mind, at which point it all starts to click together. Which makes it hard to explain or teach. But basically, think of what you're doing - whatever it is - in terms of "Things" and the "Actions" those things can do. For now, forget programming and try applying it to real-world concepts. For example, I'm here sitting at my computer. The computer is a Thing. It has a power button, which also counts as its own Thing if you really want to go that deeply into it. If I perform the Action of "press the power button" on my computer, it'll either turn on (if it's off) or start shutting down nicely (if it's on). Or I can press the power button for a few seconds, in which case it'll either turn on or it will immediately turn off. And if I were to sketch that out in some pseudo-code, it might look like thing Computer { action PressThePowerButton(HowLong) { if PoweredOn { TurnOn // doesn't matter HowLong I pressed the button for... I think } else { if HowLong == Short { TurnOffGracefully } else { TurnOffImmediately } } } } For another example, I'm hungry because I haven't eaten today, so I'm going to go into the kitchen and cook something. I'll be using my stove Thing. It has four burner Things, each wired to one of four corresponding knob Things, and I can turn the knob right/left to turn on/off the associated burner. thing Stove { has Burner1 has Burner2 has Burner3 has Burner4 has Knob1 has Knob2 has Knob3 has Knob4 action Manufacture { Knob1 = create a new Knob connected to Burner1 Knob2 = create a new Knob connected to Burner2 Knob3 = create a new Knob connected to Burner3 Knob4 = create a new Knob connected to Burner4 } } thing Knob { knows about a Burner action TurnKnobRight() { set Burner on } action TurnKnobLeft() { set Burner off } } thing Burner { has Temperature action SetOn() { Temperature = High } action SetOff() { Temperature = Off } } Basically, 95% of OOP is thinking about Things and Actions, and by doing so you can take a complicated concept and reduce it into smaller pieces that are easier to manage. Like how I didn't try to "code" all the burner and knob stuff in one place: the knob knows how to do knob things, the burner knows how to do burner things, and they're hooked up to each other. But now I'm really hungry.
  24. An API is a contract that says "if you give me X then I will give you Y". It has nothing to do with OOP. So it's totally valid to build an API with code that's procedural. In fact, a lot of OOP is just syntactic sugar over a procedural pattern. Take PHP's cURL functions for instance: you create an "instance" of a cURL thing, then call different "methods" using that thing - whether you write "curl_function($instance)" or "$instance->function()" doesn't make much of a difference. So what's your goal here? To build an API and you think you need OOP for it? Or to learn OOP using the idea of an API as a real-world example?
×
×
  • 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.